def find_object ( self , object_type ) : node = self while node is not None : if isinstance ( node . obj , object_type ) : return node . obj node = node . parent
python choose best object with attribute closest
Finds the closest object of a given type .
def find_object(self, object_type):
        """Finds the closest object of a given type."""
        node = self
        while node is not None:
            if isinstance(node.obj, object_type):
                return node.obj
            node = node.parent