Fixed algorithmic complexity of AST simplification of long expressions