from typing import OrderedDict


def dict_to_ordereddict(element):
    """ Converts nested dictionary to OrderedDict"""
    if isinstance(element, (tuple, list)):
        return [dict_to_ordereddict(item) for item in element]

    if isinstance(element, dict):
        element = OrderedDict(element)

    if isinstance(element, OrderedDict):
        for key, value in element.items():
            element[key] = dict_to_ordereddict(value)

    return element