private TopicIdPartition computeActualPartitionToBeMoved(
            TopicIdPartition partition,
            String oldOwner,
            String newOwner
        ) {
            Uuid topic = partition.topicId();

            if (!partitionMovementsByTopic.containsKey(topic))
                return partition;

            if (partitionMovementsByPartition.containsKey(partition)) {
                String expectedOldOwner = partitionMovementsByPartition.get(partition).dstMemberId;
                if (!oldOwner.equals(expectedOldOwner)) {
                    throw new PartitionAssignorException("Old owner does not match expected value for partition: " + partition);
                }
                oldOwner = partitionMovementsByPartition.get(partition).srcMemberId;
            }

            Map<MemberPair, Set<TopicIdPartition>> partitionMovementsForThisTopic = partitionMovementsByTopic.get(topic);
            MemberPair reversePair = new MemberPair(newOwner, oldOwner);
            if (!partitionMovementsForThisTopic.containsKey(reversePair))
                return partition;

            return partitionMovementsForThisTopic.get(reversePair).iterator().next();
        }
Computes the actual partition to be moved based on the current and proposed partition owners.
This method determines the appropriate partition movement, considering existing partition movements
and constraints within a topic.

@param partition         The {@link TopicIdPartition} object representing the partition to be moved.
@param oldOwner          The memberId of the current owner of the partition.
@param newOwner          The memberId of the proposed new owner of the partition.
@return The {@link TopicIdPartition} that should be moved, based on existing movement patterns
        and ownership. Returns the original partition if no specific movement pattern applies.
@throws PartitionAssignorException if the old owner does not match the expected value for the partition.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java