def tree(strings, separator='.'):
    """Return a tree of strings as a nested dictionary.

    The levels of hierarchy in each string are marked with *separator*.
    The keys in the dictionary are the sub-branch names.  The value at the
    end of each branch is the full string.

    **Arguments:**

    - *strings*: List of strings

    - *separator*: String that marks a level of hierarchy

    **Example:**

    >>> tree(['a.b.c', 'd.e', 'd.f']) # doctest: +SKIP
    {'a': {'b': {'c': 'a.b.c'}}, 'd': {'e': 'd.e', 'f': 'd.f'}}

    .. testcleanup::

       >>> tree(['a.b.c', 'd.e', 'd.f']) == {'a': {'b': {'c': 'a.b.c'}}, 'd': {'e': 'd.e', 'f': 'd.f'}}
       True
    """
    root = {}
    for string in strings:
        branch = root
        elements = string.split(separator)
        for element in elements[:-1]:
            if element not in branch:
                branch[element] = {}
            branch = branch[element]
        branch[elements[-1]] = string
    return root
