import inspect


def get_parent_module_classes(parent_level):
    """Generates a dictionary of classes in parent module namespace.

    Inspect the strack getting a reference to the module in which this
    function was called. Build a dictionary with references to all the classes
    in the namespace of that module.

    Args:
        parent_level: Number of levels to go up looking for the parent.

    Returns:
        {"class_name": class_reference}
    """

    parent_frame = inspect.stack()[parent_level][0]
    parent_module = inspect.getmodule(parent_frame)

    return {cls_tupl[0]: cls_tupl[1] for cls_tupl in
            inspect.getmembers(parent_module, inspect.isclass)}