Replaced recursive traversal with a safer implementation that uses the heap.
Merge branch 'fastinsertset'