<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ancestors(self):
 """Generate all ancestors of the Compound recursively. Yields ------ mb.Compound The next Compound above self in the hierarchy """

        if self.parent is not None:
            yield self.parent
            for ancestor in self.parent.ancestors():
                yield ancestor