def inorder(node):
    if not isinstance(node, list):
        node = [node]
for n in node:
    for left in inorder(getattr(n, 'lefts', [])):
        yield left
yield n.name
for right in inorder(getattr(n, 'rights', [])):
    yield right
print(list(inorder(tree)))
How to iterate this tree/graph