The following answer has a bug. I've submitted a pull request to the 5th Edition since that's where I originally found it but the 6th Ed also has the same code.
careercup/ctci#171
The 6th Ed code with the bug:
Ch 04. Trees and Graphs/Q4_08_First_Common_Ancestor/QuestionD.java