code: def search_ancestor(node, *node_types):
      """
      Recursively looks at the parents of a node and returns the first found node
      that matches node_types. Returns ``None`` if no matching node is found.
  
      :param node: The ancestors of this node will be checked.
      :param node_types: type names that are searched for.
      :type node_types: tuple of str
      """
      while True:
          node = node.parent
          if node is None or node.type in node_types:
              return node
  
imports: import sys
  from abc import abstractmethod, abstractproperty
  from parso._compatibility import utf8_repr, encoding
  from parso.utils import split_lines
label_desc: Use image node_id 1 for calling a global function with example usage: search_ancestor(node) and returns: node