Amazon Interview Question

Traverse a tree (BSF or DSF)