Amazon interview question

Perform depth first search on dom nodes