need DFS or BFS