Depth-first search.