Add recursive depth-first search and breadth-first search.