Google Interview Question

A variation of tree traversal.