'Traverse over tree, yielding all subtrees and leaves'

def _traverse(self):

    (yield self)
    traversals = ((arg._traverse() if isinstance(arg, Node) else [arg]) for arg in self._inputs)
    for item in concat(traversals):
        (yield item)
