from typing import OrderedDict


def _ordered_dict(loader, node):
    """
    Loads YAML mappings into an ordered dict to preserve key order.
    """
    loader.flatten_mapping(node)
    return OrderedDict(loader.construct_pairs(node))