@orbuluh I really like your solution!
I am just curious about its time complexity.
I think that the worst time complexity for the recursion part would be O(logN) (where n is the number of nodes) and the while loop part is also O(logN) for the worst case. Therefore, the time complexity is going to be O(logN).
Am I understanding it correctly?