Background: I'm using ANTLR4 (C# version) to parse a source file, then use StringTemplate4 on the parse tree to render the source file in a different language.
This works relatively well, but I regularly hit the stack depth limit, because the parse tree is very deeply nested.
Copied from antlr/stringtemplate4#111: