improv dfs aglorithm, use stack instead of recurrence