def word_tree(words):
    """
    This builds a tree according to a list of words to later be searched
    whilst looking for valid words in search(...)
    Example tree for NANDO, NATTY, NANNY and NERDS
    {'N':
      {'A': {'N': {'D': {'O': {}},
                   'N': {'Y': {}}},
             'T': {'T': {'Y': {}}}},
       'E': {'R': {'D': {'S': {}}}}}}
    """
    tree = {'N': {}}
    for w in words:
        T = tree[w[0]]
        for depth in range(1, len(w)):
            if w[depth] not in T.keys():
                T[w[depth]] = {}
            T = T[w[depth]]
    return tree