def ensure_keys(dict_obj, *keys):
    """
    Ensure ``dict_obj`` has the hierarchy ``{keys[0]: {keys[1]: {...}}}``

    The innermost key will have ``{}`` has value if didn't exist already.
    """
    if len(keys) == 0:
        return dict_obj
    else:
        first, rest = keys[0], keys[1:]
        if first not in dict_obj:
            dict_obj[first] = {}
        dict_obj[first] = ensure_keys(dict_obj[first], *rest)
        return dict_obj