Compiling a series of addition will takes a quadratic time. You should limit the exploration depth, this will avoid that problem, and you won't loose any possible optimization since the traversal of deep node was already done by previous calls that generated the addition expressions.