'od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.'

def popitem(self, last=True):

    if (not self):
        raise KeyError('dictionary    is    empty')
    root = self.__root
    if last:
        link = root.prev
        link_prev = link.prev
        link_prev.next = root
        root.prev = link_prev
    else:
        link = root.next
        link_next = link.next
        root.next = link_next
        link_next.prev = root
    key = link.key
    del self.__map[key]
    value = dict.pop(self, key)
    return (key, value)
