@Override
    public Optional<Entry<T>> lastEntry() {
        return Optional.ofNullable(history.lastEntry()).map(entry -> new Entry<>(entry.getKey(), 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