code: def inplace_delete_message_queue(
          chain_state: ChainState,
          state_change: Union[ReceiveDelivered, ReceiveProcessed],
          queueid: QueueIdentifier,
  ) -> None:
      
      queue = chain_state.queueids_to_queues.get(queueid)
      if not queue:
          return
  
      inplace_delete_message(
          message_queue=queue,
          state_change=state_change,
      )
  
      if len(queue) == 0:
          del chain_state.queueids_to_queues[queueid]
      else:
          chain_state.queueids_to_queues[queueid] = queue
docs: Filter messages from queue, if the queue becomes empty, cleanup the queue itself.