code: def enclosing_frame(frame=None, level=2):
      
      frame = frame or sys._getframe(level)
      while frame.f_globals.get('__name__') == __name__: frame = frame.f_back
      return frame
docs: Get an enclosing frame that skips decorator code