Inorder binary tree traversal
def inorder(root): curr, stack = root, [] while curr or stack: if curr: stack.append(curr) curr = curr.left else: curr = stack.pop() yield curr curr = curr.right