private static List<EpochEntry> truncateFromEnd(TreeMap<Integer, EpochEntry> epochs, long endOffset) {
        Optional<EpochEntry> epochEntry = Optional.ofNullable(epochs.lastEntry()).map(Entry::getValue);
        if (endOffset >= 0 && epochEntry.isPresent() && epochEntry.get().startOffset >= endOffset) {
            return removeWhileMatching(epochs.descendingMap().entrySet().iterator(), x -> x.startOffset >= endOffset);
        }
        return Collections.emptyList();
    }
Clears old epoch entries. This method searches for the oldest epoch < offset, updates the saved epoch offset to
be offset, then clears any previous epoch entries.
<p>
This method is exclusive: so truncateFromStart(6) will retain an entry at offset 6.
<p>
Checkpoint-flushing is done asynchronously.

@param startOffset the offset to clear up to
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java