From aecfc0e0c46f9541ca00b3835f6e2d9ba64f5f8e Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 4 Feb 2026 02:29:05 +0100 Subject: [PATCH] Avoid duplication of code --- parso/tree.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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: