code: def get_parent_scope_from_var(name, global_ok=False, skip_frames=0) -> typing.Optional[Scope]:
      
  
      stack = inspect.stack()
      try:
          for frame_info in stack[skip_frames + 1:]:
              frame = None
  
              try:
                  frame = frame_info.frame
  
                  if name in frame.f_locals or (global_ok and name in frame.f_globals):
                      return Scope(globals_=frame.f_globals, locals_=frame.f_locals)
              finally:
                  del frame
      finally:
          del stack
  
      return None
docs: Iterates up the frame stack looking for a frame-scope containing the given variable name.
  
      Returns
      --------
      Optional[Scope]
          The relevant :class:`Scope` or None