private static List<EpochEntry> truncateFromStart(TreeMap<Integer, EpochEntry> epochs, long startOffset) {
        List<EpochEntry> removedEntries = removeWhileMatching(
                epochs.entrySet().iterator(), entry -> entry.startOffset <= startOffset);

        if (!removedEntries.isEmpty()) {
            EpochEntry firstBeforeStartOffset = removedEntries.get(removedEntries.size() - 1);
            EpochEntry updatedFirstEntry = new EpochEntry(firstBeforeStartOffset.epoch, startOffset);
            epochs.put(updatedFirstEntry.epoch, updatedFirstEntry);
        }

        return removedEntries;
    }
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