def set_value_by_dot(doc, key, value):
    """Set dictionary value using dotted key"""
    result = doc
    keys = key.split('.')
    for i in keys[:-1]:
        if i not in result:
            result[i] = {}
        result = result[i]
    result[keys[-1]] = value
    return doc