<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def next_primary_replica_name_for_backup(self, instance_id, master_primary_rank, primaries, node_reg, node_ids):
 """ Returns name and corresponding instance name of the next node which is supposed to be a new Primary for backup instance in round-robin fashion starting from primary of master instance. """

        if node_reg is None:
            node_reg = self.node.nodeReg
        total_nodes = len(node_reg)
        rank = (master_primary_rank + 1) % total_nodes
        name = self.node.get_name_by_rank(rank, node_reg, node_ids)
        while name in primaries:
            rank = (rank + 1) % total_nodes
            name = self.node.get_name_by_rank(rank, node_reg, node_ids)
        return name, Replica.generateName(nodeName=name, instId=instance_id)