def add_keys(destdict, srclist, value=None):
    """
    Nests keys from srclist into destdict, with optional value set on the final key.

    :param dict destdict: the dict to update with values from srclist
    :param list srclist: list of keys to add to destdict
    :param value: final value to set
    :return: destination dictionary
    :rtype: dict
    """
    if len(srclist) > 1:
        destdict[srclist[0]] = {}
        destdict[srclist[0]] = destdict.get(srclist[0], {})
        add_keys(destdict[srclist[0]], srclist[1:], value)
    else:
        destdict[srclist[0]] = value
    return destdict