def expand_items(form_values, sep='.'):
    '''
    Parameters
    ----------
    form_values : list
        List of ``(key, value)`` tuples, where ``key`` corresponds to the
        ancestor keys of the respective value joined by ``'.'``.  For example,
        the key ``'a.b.c'`` would be expanded to the dictionary
        ``{'a': {'b': {'c': 'foo'}}}``.

    Returns
    -------
    dict
        Nested dictionary, where levels are inferred from each key by splitting
        on ``'.'``.
    '''
    output = {}
    for keys_str_i, value_i in form_values:
        keys_i = keys_str_i.split(sep)
        parents_i = keys_i[:-1]
        fieldname_i = keys_i[-1]

        dict_j = output
        for key_j in parents_i:
            dict_j = dict_j.setdefault(key_j,  {})
        dict_j[fieldname_i] = value_i
    return output