def ordereddict_change_key(d, old, new):
    """Rename the key of an ordered dict without changing the order"""
    # from https://stackoverflow.com/a/17747040
    d2 = d.copy()
    for _ in range(len(d2)):
        k, v = d2.popitem(False)
        d2[new if old == k else k] = v
    return d2