Google Interview Question

DFS approach of the tree?