public static Optional<FetchSnapshotResponseData.PartitionSnapshot> forTopicPartition(
        FetchSnapshotResponseData data,
        TopicPartition topicPartition
    ) {
        return data
            .topics()
            .stream()
            .filter(topic -> topic.name().equals(topicPartition.topic()))
            .flatMap(topic -> topic.partitions().stream())
            .filter(partition -> partition.index() == topicPartition.partition())
            .findAny();
    }
Finds the PartitionSnapshot for a given topic partition.

@param data the fetch snapshot response data
@param topicPartition the topic partition to find
@return the response partition snapshot if found, otherwise an empty Optional
clients/src/main/java/org/apache/kafka/common/requests/FetchSnapshotResponse.java