It is often convenient to write the operations on trees as recursive methods. This is because the tree is itself defined recursively.
Also the recursive code serves as an inductive proof of correctness.
- Base case: empty tree - just return null (obviously the code is correct for this case)
- The correctness of method get for a tree is reduced to the correctness for the smaller trees: the left subtree and the right subtree.
Inductively, the correctness of the subtrees can be reduced down to the base case, which is obviously correct.