def _map_field(mapping, field, properties=None):
    """
    Takes a mapping dictionary, a field name, and a properties dictionary.
    If the field is nested (e.g., 'user.name'), returns a nested mapping
    dictionary.
    """
    fields = field.split('.', 1)

    if properties is None:
        properties = {'properties': {}}

    if 'properties' not in properties:
        properties['properties'] = {}

    # base case: not a nested field
    if len(fields) == 1:
        new_map = {fields[0]: mapping}
        properties['properties'].update(new_map)

    # recursive case: nested field
    else:
        if fields[0] in properties['properties']:
            new_properties = properties['properties'][fields[0]]
            new_map = _map_field(mapping, fields[1], new_properties)
            properties['properties'][fields[0]].update(new_map)
        else:
            new_map = _map_field(mapping, fields[1])
            properties['properties'][fields[0]] = new_map

    return properties