code: 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
docs: Finds the closest object of a given type.