diff --git a/parso/tree.py b/parso/tree.py index e529871..7935308 100644 --- a/parso/tree.py +++ b/parso/tree.py @@ -14,12 +14,7 @@ def search_ancestor(node: 'NodeOrLeaf', *node_types: str) -> 'Optional[BaseNode] :param node: The ancestors of this node will be checked. :param node_types: type names that are searched for. """ - n = node.parent - while n is not None: - if n.type in node_types: - return n - n = n.parent - return None + return node.search_ancestor(*node_types) class NodeOrLeaf: