TraceStack: when visiting a range preallocate the elements.

Improves performance of raytrace.py from about 10secs to 7secs.