code: def get_channelstate_by_token_network_and_partner(
          chain_state: ChainState,
          token_network_id: TokenNetworkID,
          partner_address: Address,
  ) -> Optional[NettingChannelState]:
      
      token_network = get_token_network_by_identifier(
          chain_state,
          token_network_id,
      )
  
      channel_state = None
      if token_network:
          channels = [
              token_network.channelidentifiers_to_channels[channel_id]
              for channel_id in token_network.partneraddresses_to_channelidentifiers[partner_address]
          ]
          states = filter_channels_by_status(
              channels,
              [CHANNEL_STATE_UNUSABLE],
          )
          if states:
              channel_state = states[-1]
  
      return channel_state
docs: Return the NettingChannelState if it exists, None otherwise.