Siemens interview question

tranverse a tree