private ExpressionNode transformArithmetic(OperationNode node) {
        // Fold the subset of expressions that are constant (such that in "1 + 2 + var")
        if (node.children().size() > 1) {
            List<ExpressionNode> children = new ArrayList<>(node.children());
            List<Operator> operators = new ArrayList<>(node.operators());
            for (Operator operator : Operator.operatorsByPrecedence)
                transform(operator, children, operators);
            if (operators.isEmpty() && children.size() == 1) {
                return children.get(0);
            }
            node = new OperationNode(children, operators);
        }

        if (isConstant(node) && ! node.evaluate(null).isNaN())
            return new ConstantNode(node.evaluate(null));
        else if (allMultiplicationOrDivision(node) && hasZero(node) && ! hasDivisionByZero(node))
            return new ConstantNode(new DoubleValue(0));
        else
            return node;
    }
Performs simple algebraic simplification of expressions

@author bratseth
searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/transform/Simplifier.java