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
      values = []
      for x in ast.walk(node):
          if isinstance(x, (ast.stmt, ast.ExceptHandler)):
              values.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
                      values.append(val[0].lineno - 1 - 1)
      values.sort()
      insert_index = bisect_right(values, lineno)
      start = values[insert_index - 1]
      if insert_index >= len(values):
          end = None
      else:
          end = values[insert_index]
      return start, end
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import ast
  import inspect
  import linecache
  import sys
  import textwrap
  import tokenize
  import warnings
  from ast import PyCF_ONLY_AST
  from bisect import bisect_right
  import py
  import six
label_desc: Use image node_id 6 for calling a global function with example usage: get_statement_startend2(lineno, node) and returns: start,  end