def _dict_from_dotted(key, val):
    """takes a key value pair like:
    key: "this.is.a.key"
    val: "the value"

    and returns a dictionary like:

    {"this":
        {"is":
            {"a":
                {"key":
                    "the value"
                }
            }
        }
    }
    """
    split_key = key.split(".")
    split_key.reverse()
    for key_part in split_key:
        new_dict = DotDict()
        new_dict[key_part] = val
        val = new_dict
    return val