code: def ancestors(self):
          
          if self.parent is not None:
              yield self.parent
              for ancestor in self.parent.ancestors():
                  yield ancestor
docs: Generate all ancestors of the Compound recursively.
  
          Yields
          ------
          mb.Compound
              The next Compound above self in the hierarchy