non-recursive dfs