Non recursive reverse depth first search.