Removes occurrences of given item in ascending priority. Default
        number of removals is 1. Useful for tasks that no longer require
        completion, inactive clients, certain algorithms, etc. Returns a
        list of tuple(item, priority). Performance: O(n)

def remove(self, item, count=1):
        """Removes occurrences of given item in ascending priority. Default
        number of removals is 1. Useful for tasks that no longer require
        completion, inactive clients, certain algorithms, etc. Returns a
        list of tuple(item, priority). Performance: O(n)"""

        with self.lock:

            try:
                count = int(count)
            except ValueError as ex:
                ex.args = ('{} cannot be represented as an '
                           'integer'.format(count),)
                raise
            except TypeError as ex:
                ex.args = ('{} cannot be represented as an '
                           'integer'.format(count),)
                raise

            removed = []
            self_items = self.items

            try:
                item_freq = self_items[item]
                item_repr = item
                if item_freq == 0:
                    return removed
            except TypeError:
                item_freq = self_items[repr(item)]
                item_repr = repr(item)
                if item_freq == 0:
                    return removed

            if count == -1:
                count = item_freq

            self_data = self.data
            rotate = self_data.rotate
            pop = self_data.pop
            counter = 0

            for i in range(len(self_data)):
                if count > counter and item == self_data[-1][0]:
                    removed.append(pop())
                    counter += 1
                    continue
                rotate()

            if item_freq <= count:
                del self_items[item_repr]
            else:
                self_items[item_repr] -= count

            return removed