'Extract _ConsumerDeliveryEvt objects destined for the given consumer
from pending events, discarding the _ConsumerCancellationEvt, if any
:param str consumer_tag:
:returns: a (possibly empty) sequence of _ConsumerDeliveryEvt destined
for the given consumer tag'

def _remove_pending_deliveries(self, consumer_tag):

    remaining_events = deque()
    unprocessed_messages = []
    while self._pending_events:
        evt = self._pending_events.popleft()
        if (type(evt) is _ConsumerDeliveryEvt):
            if (evt.method.consumer_tag == consumer_tag):
                unprocessed_messages.append(evt)
                continue
        if (type(evt) is _ConsumerCancellationEvt):
            if (evt.method_frame.method.consumer_tag == consumer_tag):
                continue
        remaining_events.append(evt)
    self._pending_events = remaining_events
    return unprocessed_messages
