code: def get_channelstate_by_canonical_identifier(
          chain_state: ChainState,
          canonical_identifier: CanonicalIdentifier,
  ) -> Optional[NettingChannelState]:
      
      token_network = get_token_network_by_identifier(
          chain_state,
          TokenNetworkID(canonical_identifier.token_network_address),
      )
  
      channel_state = None
      if token_network:
          channel_state = token_network.channelidentifiers_to_channels.get(
              canonical_identifier.channel_identifier,
          )
  
      return channel_state
docs: Return the NettingChannelState if it exists, None otherwise.