Amazon Interview Question

Perform depth first search on dom nodes