Binary Trees & the Genre Tree
In short: a binary tree is made of nodes, each holding a value and up
to two children, left and right — a missing child is None. Recursion
walks it naturally, because every child starts its own subtree that
follows exactly the same rules. The three depth-first orders — pre-, in-
and post-order — differ only in when a node is recorded relative to its
two children; breadth-first (level order) visits every node at one depth
before any node at the next, using a queue. Every walk touches each node
once, so all of them cost O(n) time; the extra space is O(h) for
recursion's call stack, or O(w) for a queue, where h is the height and w the
widest level.

Grow the genre tree from Tunebox's JSON
Tunebox's genres aren't a flat list. Music splits into Rock and Electronic; Rock splits into Punk and Metal. A list can hold those names, but it can't say that Punk sits under Rock — a tree can:
The top node is the root; a node with no children is a leaf. Tunebox
actually ships the tree as JSON, level by level, left to right, with
None for a missing child: ["Music", "Rock", "Electronic", "Punk", "Metal", None, "House"]. A queue rebuilds it — the first value is the root,
and after that, values arrive in pairs, the left and right child of each real
node in turn. The easy mistake is forgetting that a None still claims its
pair slot even though it gets no children of its own:
Height is how tall a tree is — we count nodes on the longest root-to-leaf path, so an empty tree has height 0 and a lone root height 1. Height is recursion in its purest form: a tree is one node taller than its taller subtree.
class Node:
def __init__(self, val, left=None, right=None):
self.val, self.left, self.right = val, left, right
def height(node):
if node is None:
return 0
return 1 + max(height(node.left), height(node.right))
jazz = Node("Jazz", Node("Bebop", None, Node("Hard Bop")), Node("Swing"))
print(height(jazz))