A binary tree is made of nodes; each node has a value and at most two children: left and right. The node at the top is the root, those without children are leaves. The point is this: a node's left and its right are each a tree in their own right. That is why tree questions suit recursion so well.
def total(node):if node is None:return 0return node.val + total(node.left) + total(node.right)
The order in which you visit the nodes has names. In-order: the left subtree first, then the node itself, then the right. Pre-order: node, left, right. Post-order: left, right, node. The only difference is where the line about the node stands relative to the two calls.