code: def get_toplevel_parent(self, treeitem):
          
          tv = self.treeview
          toplevel_items = tv.get_children()
  
          item = treeitem
          while not (item in toplevel_items):
              item = tv.parent(item)
  
          return item
docs: Returns the top level parent for treeitem.