unrolling forests without recursion