Adaptive depth first search.