Tradeoff: instead of having memoized results for searching nodes, make it tail-recursive.