class MyOrderedDict(OrderedDict):

    def next_key(self, key):
        next = self._OrderedDict__map[key][1]
if next is self._OrderedDict__root:
    raise ValueError('{!r} is the last key'.format(key))
return next[2]

def first_key(self):
    for key in self:
        return key
raise ValueError('OrderedDict() is empty')
od = MyOrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)])
od.next_key('apple')
od.next_key('banana')
od.next_key('orange')
od.next_key('pear')
od.first_key()
Как получить «следующий» элемент в OrderedDict?