DFS->while loop