code: def get_channelstate_filter(
          chain_state: ChainState,
          payment_network_id: PaymentNetworkID,
          token_address: TokenAddress,
          filter_fn: Callable,
  ) -> List[NettingChannelState]:
      
      token_network = get_token_network_by_token_address(
          chain_state,
          payment_network_id,
          token_address,
      )
  
      result: List[NettingChannelState] = []
      if not token_network:
          return result
  
      for channel_state in token_network.channelidentifiers_to_channels.values():
          if filter_fn(channel_state):
              result.append(channel_state)
  
      return result
docs: Return the state of channels that match the condition in `filter_fn`