DFS, BFS with no duplicate nodes