docstr: Searches names that are defined in a scope (the different
  ``filters``), until a name fits.
docstr_tok: ["Searches","names","that","are","defined","in","a","scope","(","the","different","``","filters","``",")",",","until","a","name","fits","."]
code: def filter_name(self, filters):
      """
      Searches names that are defined in a scope (the different
      ``filters``), until a name fits.
      """
      names = []
      if self._context.predefined_names and isinstance(
          self._name, tree.Name
      ):
          node = self._name
          while node is not None and not is_scope(node):
              node = node.parent
              if node.type in ("if_stmt", "for_stmt", "comp_for"):
                  try:
                      name_dict = self._context.predefined_names[node]
                      types = name_dict[self._string_name]
                  except KeyError:
                      continue
                  else:
                      self._found_predefined_types = types
                      break
  
      for filter in filters:
          names = filter.get(self._string_name)
          if names:
              if len(names) == 1:
                  (n,) = names
                  if isinstance(n, TreeNameDefinition):
                      # Something somewhere went terribly wrong. This
                      # typically happens when using goto on an import in an
                      # __init__ file. I think we need a better solution, but
                      # it's kind of hard, because for Jedi it's not clear
                      # that that name has not been defined, yet.
                      if n.tree_name == self._name:
                          if (
                              self._name.get_definition().type
                              == "import_from"
                          ):
                              continue
              break
  
      debug.dbg(
          "finder.filter_name %s in (%s): %s@%s",
          self._string_name,
          self._context,
          names,
          self._position,
      )
      return list(names)
  
imports: from parso.python import tree
  from parso.tree import search_ancestor
  from jedi import debug
  from jedi import settings
  from jedi.evaluate.context import AbstractInstanceContext
  from jedi.evaluate import compiled
  from jedi.evaluate import analysis
  from jedi.evaluate import flow_analysis
  from jedi.evaluate.arguments import TreeArguments
  from jedi.evaluate import helpers
  from jedi.evaluate.context import iterable
  from jedi.evaluate.filters import get_global_filters, TreeNameDefinition
  from jedi.evaluate.base_context import ContextSet
  from jedi.parser_utils import is_scope, get_parent_scope
label_desc: Use image node_id 5 for calling the NameFinder obj's underlying member method code with example usage: obj.filter_name(filters) and returns: list