

def get_ancestor(self, klass):
    '\n        Walks the nodes tree upwards until it finds a node of the class\n        ``klass`` or returns None.\n\n        Returns:\n            CocosNode or None\n        '
    if isinstance(self, klass):
        return self
    parent = self.parent
    if parent:
        return parent.get_ancestor(klass)

dataset/ETHPy150Open los-cocos/cocos/cocos/cocosnode.py CocosNode.get_ancestor/original