def get_dotted_key(dictionary, key_str, default=None):
    """Fetch a value from a nested dictionary with keys of the form a.b.c"""
    key_list = key_str.split('.')
    key_val = key_list.pop()

    for key in key_list:
        try:
            dictionary = dictionary[key]
        except (KeyError, ValueError):
            return default

    return dictionary.get(key_val, default)