Stack capture is really only useful from tests
The library uses a list rather than an array everywhere, so provide a utility for getting that list
Separate cycle detection from stack transformation