<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detect_balance_proof_change( old_state: ChainState, current_state: ChainState, ) -> Iterator[Union[BalanceProofSignedState, BalanceProofUnsignedState]]: """ Compare two states for any received balance_proofs that are not in `old_state`. """

    if old_state == current_state:
        return
    for payment_network_identifier in current_state.identifiers_to_paymentnetworks:
        try:
            old_payment_network = old_state.identifiers_to_paymentnetworks.get(
                payment_network_identifier,
            )
        except AttributeError:
            old_payment_network = None

        current_payment_network = current_state.identifiers_to_paymentnetworks[
            payment_network_identifier
        ]
        if old_payment_network == current_payment_network:
            continue

        for token_network_identifier in current_payment_network.tokenidentifiers_to_tokennetworks:
            if old_payment_network:
                old_token_network = old_payment_network.tokenidentifiers_to_tokennetworks.get(
                    token_network_identifier,
                )
            else:
                old_token_network = None

            current_token_network = current_payment_network.tokenidentifiers_to_tokennetworks[
                token_network_identifier
            ]
            if old_token_network == current_token_network:
                continue

            for channel_identifier in current_token_network.channelidentifiers_to_channels:
                if old_token_network:
                    old_channel = old_token_network.channelidentifiers_to_channels.get(
                        channel_identifier,
                    )
                else:
                    old_channel = None

                current_channel = current_token_network.channelidentifiers_to_channels[
                    channel_identifier
                ]
                if current_channel == old_channel:
                    continue

                else:
                    partner_state_updated = (
                        current_channel.partner_state.balance_proof is not None and
                        (
                            old_channel is None or
                            old_channel.partner_state.balance_proof !=
                            current_channel.partner_state.balance_proof
                        )
                    )

                    if partner_state_updated:
                        assert current_channel.partner_state.balance_proof, MYPY_ANNOTATION
                        yield current_channel.partner_state.balance_proof

                    our_state_updated = (
                        current_channel.our_state.balance_proof is not None and
                        (
                            old_channel is None or
                            old_channel.our_state.balance_proof !=
                            current_channel.our_state.balance_proof
                        )
                    )

                    if our_state_updated:
                        assert current_channel.our_state.balance_proof, MYPY_ANNOTATION
                        yield current_channel.our_state.balance_proof