Tail recursive optimization for iterative deepening depth-first search.