Synopsys interview question

Solve a problem related to tree traversal.