'Iterate over all descendant nodes in depth-first order.'

def iterdescendants(self, breadth_first=False):

    if breadth_first:
        for child in self.nodes:
            (yield child)
        for child in self.nodes:
            for node in child.iterdescendants(breadth_first=True):
                (yield node)
    else:
        for child in self.nodes:
            for node in child.iter():
                (yield node)
