Both algorithms use the same invariant: every node must sit strictly inside the open window (minVal, maxVal)
handed down by its ancestors — a node's value becomes maxVal for its left subtree, minVal for its right subtree.
Only the order in which nodes are visited changes.
(minVal, maxVal)