code: def find_binding(name, node, package=None):
      """Returns the node which binds variable name, otherwise None.
      If optional argument package is supplied, only imports will
      be returned.
      See test cases for examples."""
      for child in node.children:
          ret = None
          if child.type == syms.for_stmt:
              if _find(name, child.children[1]):
                  return child
              n = find_binding(
                  name, make_suite(child.children[-1]), package
              )
              if n:
                  ret = n
          elif child.type in (syms.if_stmt, syms.while_stmt):
              n = find_binding(
                  name, make_suite(child.children[-1]), package
              )
              if n:
                  ret = n
          elif child.type == syms.try_stmt:
              n = find_binding(
                  name, make_suite(child.children[2]), package
              )
              if n:
                  ret = n
              else:
                  for i, kid in enumerate(child.children[3:]):
                      if kid.type == token.COLON and kid.value == ":":
                          # i+3 is the colon, i+4 is the suite
                          n = find_binding(
                              name,
                              make_suite(child.children[i + 4]),
                              package,
                          )
                          if n:
                              ret = n
          elif (
              child.type in _def_syms
              and child.children[1].value == name
          ):
              ret = child
          elif _is_import_binding(child, name, package):
              ret = child
          elif child.type == syms.simple_stmt:
              ret = find_binding(name, child, package)
          elif child.type == syms.expr_stmt:
              if _find(name, child.children[0]):
                  ret = child
  
          if ret:
              if not package:
                  return ret
              if is_import(ret):
                  return ret
      return None
  
imports: from itertools import islice
  from .pgen2 import token
  from .pytree import Leaf, Node
  from .pygram import python_symbols
  from .None import patcomp
label_desc: Use image node_id 30 for calling a global function with example usage: find_binding(name, node, package) and returns: None, child, ret, ret