private Expression optimizeStatement(StatementExpression statement) {
        List<Expression> expressionList = new ArrayList<>();
        List<Expression> candidateList = new ArrayList<>();
        for (Expression exp : statement) {
            if (ignoresInput(exp)) {
                candidateList.clear();
            }
            candidateList.add(convert(exp));
            if (hasSideEffect(exp)) {
                expressionList.addAll(candidateList);
                candidateList.clear();
            }
        }
        expressionList.addAll(candidateList);
        return new StatementExpression(expressionList);
    }
Optimizes expressions by removing expressions that have no effect.
Typical examples are statements that come before a statement that
generates a new execution value without regard for the existing one.
indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/ExpressionOptimizer.java