I'm concerned that using recursion here could lead to stack overflows if the tree grows deep.