Avoid duplication of code

This commit is contained in:
Dave Halter
2026-02-04 02:29:05 +01:00
parent 3158571e46
commit aecfc0e0c4

View File

@@ -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: