Allow depth-first or breadth-first search