Optional<BatchMetadata> batchWithSequenceRange(int firstSeq, int lastSeq) {
        Stream<BatchMetadata> duplicate = batchMetadata.stream().filter(metadata -> firstSeq == metadata.firstSeq() && lastSeq == metadata.lastSeq);
        return duplicate.findFirst();
    }
Check if the sequence number is in the range [start, end] (inclusive).
The range may wrap around the sequence space.
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateEntry.java