def truncate_ordered_dict(d, max_length=10):
    """
    Truncate an ordered dict starting from the oldest entries
    until it has the given maximum length

    :param d: OrderedDict instance
    :param int max_count: Maximum length of the dict
    """
    while len(d) > max_length:
        d.popitem(last=False)
