Add DFS implementation.