def find_root ( self ) : cmd = self while cmd . parent : cmd = cmd . parent return cmd
python how to get parent of self
Traverse parent refs to top .
def find_root(self):
        """ Traverse parent refs to top. """
        cmd = self
        while cmd.parent:
            cmd = cmd.parent
        return cmd