Does node
have a property parent
? And if it does, is that property of type Node
? If so, the answer should be obvious to you (if you're comfortable with recursion).
Remember that all recursive functions must have an exit condition. What do you think the exit condition for this function should be?