code: def flatten(self) :
  		
  		if len(self.children) > 1 :
  			children = self.children
  			self.emptyChildren()
  			
  			children[0].emptyChildren()
  			x1 = children[0].x1
  			x2 = children[0].x2
  			refObjs = [children[0].referedObject]
  			name = children[0].name
  			
  			for i in range(1, len(children)) :
  				children[i].emptyChildren()
  				if children[i-1] >= children[i] :
  					x2 = children[i].x2
  					refObjs.append(children[i].referedObject)
  					name += " U " + children[i].name
  				else :
  					if len(refObjs) == 1 :
  						refObjs = refObjs[0]
  		
  					self.insert(x1, x2, name, refObjs)
  					x1 = children[i].x1
  					x2 = children[i].x2
  					refObjs = [children[i].referedObject]
  					name = children[i].name
  			
  			if len(refObjs) == 1 :
  				refObjs = refObjs[0]
  		
  			self.insert(x1, x2, name, refObjs)
docs: Flattens the tree. The tree become a tree of depth 1 where overlapping regions have been merged together