Amazon interview question

Traverse a tree (BSF or DSF)