code: def _lookup_parent(self, cls):
          
          codeobj = self.parent
          while codeobj is not None and not isinstance(codeobj, cls):
              codeobj = codeobj.parent
          return codeobj
docs: Lookup a transitive parent object that is an instance
              of a given class.