Avoid stack overflows in TreeAccumulator
Avoid stack overflows in TreeAccumulator

The previously optimized apply function was not tail recursive since
it was not final.

sjrd/dotty,sjrd/dotty,lampepfl/dotty,lampepfl/dotty,dotty-staging/dotty,dotty-staging/dotty,dotty-staging/dotty,lampepfl/dotty,lampepfl/dotty,sjrd/dotty,lampepfl/dotty,dotty-staging/dotty,dotty-staging/dotty,sjrd/dotty,sjrd/dotty