Add check for DFS vs BFS