That is the depth of the left_child, and therefore the depth of the tree, as it is the greatest depth.
What is difficult to see is that each recursion is handing in a smaller object. Once the increment reaches an empty object, or a non-existing one, it passes the not tree test and recursion stops. We don’t see the 0 unless the tree is empty to start. What we see when the call stack winds down, in this case, 2, is after all the returns.
During recursion, the returns are abeyed, and reside temporarily in a call stack. When the base case has been reached, (return 0), that is the signal to begin popping off the returns in the call stack, which in turn accumulate until the last return is handled. It is that return that the initial caller sees.
Even less obvious in all of this is that returns depend upon the previous return value, so there is no way to resolve any of them if the stack doesn’t wind down.
This is what happens when the call stack runs out of space:
Halt, And Catch Fire.
A runaway recursion will eat up the call stack space in no time. When that happens, check your base case, first, then look for errors.
crashing is a good way of halting, and burning is a good way of catching fire.