presto-main/src/main/java/io/prestosql/util/Mergeable.java/Mergeable/merge
class Mergeable:    static <T extends Mergeable<T>> Optional<T> merge(Optional<T> first, Optional<T> second)
    {
        if (first.isPresent() && second.isPresent()) {
            return Optional.of(first.get().mergeWith(second.get()));
        }
        if (first.isPresent()) {
            return first;
        }

        return second;
    }