private double toValue(ExpressionNode node) {
        if (node instanceof ConstantNode) {
            Value value = ((ConstantNode)node).getValue();
            if (value instanceof DoubleCompatibleValue || value instanceof StringValue)
                return value.asDouble();
            else
                throw new IllegalArgumentException("Cannot optimize a node containing a value of type " +
                                                   value.getClass().getSimpleName() + " (" + value + ") in a set test: " + node);
        }

        if (node instanceof NegativeNode nNode) {
            if (!(nNode.getValue() instanceof ConstantNode)) {
                throw new IllegalArgumentException("Contained a negation of a non-number: " + nNode.getValue());
            }
            return -((ConstantNode)nNode.getValue()).getValue().asDouble();
        }
        throw new IllegalArgumentException("Node could not be optimized: " + node);
    }
Consumes the if condition and return the size of the values resulting, for convenience
searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/gbdtoptimization/GBDTOptimizer.java