Add support for online decision-making on whether to do BFS or DFS