[algorithm] Non-recursive depth first search algorithm