code: def get_statement_startend2(lineno, node):
      import ast
  
      # flatten all statements and except handlers into one lineno-list
      # AST's line numbers start indexing at 1
      l = []
      for x in ast.walk(node):
          if isinstance(x, _ast.stmt) or isinstance(
              x, _ast.ExceptHandler
          ):
              l.append(x.lineno - 1)
              for name in "finalbody", "orelse":
                  val = getattr(x, name, None)
                  if val:
                      # treat the finally/orelse part as its own statement
                      l.append(val[0].lineno - 1 - 1)
      l.sort()
      insert_index = bisect_right(l, lineno)
      start = l[insert_index - 1]
      if insert_index >= len(l):
          end = None
      else:
          end = l[insert_index]
      return start, end
  
imports: from __future__ import generators
  from bisect import bisect_right
  import sys
  import inspect, tokenize
  import py
  from types import ModuleType
label_desc: Use image node_id 6 for calling a global function with example usage: get_statement_startend2(lineno, node) and returns: start,  end