Replaced recursive traversal with a safer implementation that uses the heap.