default Optional<Long> offsetOfMaxTimestamp() {
        if (magic() == RecordBatch.MAGIC_VALUE_V0) return Optional.empty();
        long maxTimestamp = maxTimestamp();
        try (CloseableIterator<Record> iter = streamingIterator(BufferSupplier.create())) {
            while (iter.hasNext()) {
                Record record = iter.next();
                if (maxTimestamp == record.timestamp()) return Optional.of(record.offset());
            }
        }
        return Optional.empty();
    }
iterate all records to find the offset of max timestamp.
noted:
1) that the earliest offset will return if there are multi records having same (max) timestamp
2) it always returns None if the {@link RecordBatch#magic()} is equal to {@link RecordBatch#MAGIC_VALUE_V0}
@return offset of max timestamp
clients/src/main/java/org/apache/kafka/common/record/RecordBatch.java