Google interview question

Python coding problem about trees