[fixes] setup control
diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py
index 0f4f6a1..60d2957 100644
--- a/setup/doctype/setup_control/setup_control.py
+++ b/setup/doctype/setup_control/setup_control.py
@@ -271,7 +271,7 @@
 	country = webnotes.conn.get_value("Control Panel", None, "country")
 	root_territory = get_root_of("Territory")
 	for name in (country, "Rest Of The World"):
-		if not webnotes.conn.exists("Territory", name):
+		if name and not webnotes.conn.exists("Territory", name):
 			webnotes.bean({
 				"doctype": "Territory",
 				"territory_name": name,
diff --git a/setup/utils.py b/setup/utils.py
index 04c4527..c343ed1 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -32,14 +32,15 @@
 def get_root_of(doctype):
 	"""Get root element of a DocType with a tree structure"""
 	result = webnotes.conn.sql_list("""select name from `tab%s` 
-		where lft=1 and rgt=(select max(rgt) from `tab%s`)""" % (doctype, doctype))
+		where lft=1 and rgt=(select max(rgt) from `tab%s` where docstatus < 2)""" % 
+		(doctype, doctype))
 	return result[0] if result else None
 	
 def get_ancestors_of(doctype, name):
 	"""Get ancestor elements of a DocType with a tree structure"""
 	lft, rgt = webnotes.conn.get_value(doctype, name, ["lft", "rgt"])
 	result = webnotes.conn.sql_list("""select name from `tab%s` 
-		where lft<%s and rgt>%s""" % (doctype, "%s", "%s"), (lft, rgt))
+		where lft<%s and rgt>%s and docstatus < 2""" % (doctype, "%s", "%s"), (lft, rgt))
 	return result or None
 
 @webnotes.whitelist()