Amazon interview question

I was asked to solve one coding question that involved knowledge in DFS and binary trees