'Generator that returns the leaves of the tree'

def leaves(self):

    for child in self.children:
        for x in child.leaves():
            (yield x)
    if (not self.children):
        (yield self)
