@SafeVarargs
    public static <T extends Comparable<T>> Optional<T> max(Optional<T>... optionals) {
        Optional<T> best = Optional.empty();
        for (Optional<T> optional : optionals)
            if (best.isEmpty() || optional.isPresent() && optional.get().compareTo(best.get()) > 0)
                best = optional;
        return best;
    }
Returns the non-empty optional with the highest value, or empty if all are empty.
vespajlib/src/main/java/com/yahoo/collections/Optionals.java