First of all, you should prefer non-recursive solutions in such cases. A tree can have any depth, so, theoretically speaking, you can face stack overflow (and even practically, for big data sets). Also, recursion may compromise your performance. Trees are perfectly searched iteratively.
Recursion should be used in more appropriate situations. Say, you have some metadata with classes (meta-classes). The inheritance depth is never too high, so you can easily walk up the hierarchy in any direction. There are many other cases when recursion is good.
Now, about recursion. It looks like you don't know what is that. Otherwise you would at least try it. Please see:
Recursion — Wikipedia, the free encyclopedia
Recursion (computer science) — Wikipedia, the free encyclopedia
Isn't that clear already? If not, I don't want to give you the whole solution. You really need to do all the basic work all by yourself, otherwise you could not learn anything. So, you need only one hint: during execution of the code of
, you have to call
— on other node. Also, you need to break
out of recursion eventually and not allow "infinite" recursion. Please see: Broken Recursion
By the way, did you get my saying referenced above? Not that this joke is really funny, but, in a way, it's true. Another thing is funny: not only the post talks about "infinite" (or not) recursion, but the nature of the speculations is recursive reasoning, also "infinite". :-)