complete depth-first search