private boolean optimize(ExpressionNode node, List<Double> forest) {
        if (node instanceof GBDTNode) {
            addTo(forest, (GBDTNode)node);
            currentTreesOptimized++;
            return true;
        }
        if (!(node instanceof OperationNode aNode)) {
            return false;
        }
        for (Operator op : aNode.operators()) {
            if (op != Operator.plus) {
                return false;
            }
        }
        for (ExpressionNode child : aNode.children()) {
            if (!optimize(child, forest)) {
                return false;
            }
        }
        return true;
    }
Optimize the given node, if it is the root of a gdbt forest. Otherwise do nothing and return false
searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/gbdtoptimization/GBDTForestOptimizer.java