def combine(self, rhs):
<EOL>self._check_compatible_regs(rhs)<EOL>combined_qregs = deepcopy(self.qregs)<EOL>combined_cregs = deepcopy(self.cregs)<EOL>for element in rhs.qregs:<EOL><INDENT>if element not in self.qregs:<EOL><INDENT>combined_qregs.append(element)<EOL><DEDENT><DEDENT>for element in rhs.cregs:<EOL><INDENT>if element not in self.cregs:<EOL><INDENT>combined_cregs.append(element)<EOL><DEDENT><DEDENT>circuit = QuantumCircuit(*combined_qregs, *combined_cregs)<EOL>for instruction_context in itertools.chain(self.data, rhs.data):<EOL><INDENT>circuit.append(*instruction_context)<EOL><DEDENT>return circuit<EOL>
Append rhs to self if self contains compatible registers.

Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
circuits.

Return self + rhs as a new object.