@Override
    public Optional<T> valueAtOrBefore(long offset) {
        return Optional.ofNullable(history.floorEntry(offset)).map(Map.Entry::getValue);
    }
A implementation for {@code LogHistory} which uses a red-black tree to store values sorted by offset.
raft/src/main/java/org/apache/kafka/raft/internals/TreeMapLogHistory.java