Tree solutions, 18-20 lines
class WordDictionary:\n    \n        def __init__(self):\n            self.root = {}\n        \n        def addWord(self, word):\n            node = self.root\n
    class WordDictionary:\n    \n        def __init__(self):\n            self.root = {}\n        \n        def addWord(self, word):\n            node = self.root\n            for char in word:\n                node = node.setdefault(char, {})\n            node[None] = None\n    \n        def search(self, word):\n            def find(word, node):\n                if not word:\n                    return None in node\n                char, word = word[0], word[1:]\n                if char != '.':\n                    return char in node and find(word, node[char])\n                return any(find(word, kid) for kid in node.values() if kid)\n            return find(word, self.root)\n\nAn iterative alternative for the `search` method:\n\n        def search(self, word):\n            nodes = [self.root]\n            for char in word:\n                nodes = [kid\n                         for node in nodes\n                         for key, kid in node.items()\n                         if char in (key, '.') and kid]\n            return any(None in node for node in nodes)\n\nAnd one that's a bit longer but faster:\n\n        def search(self, word):\n            nodes = [self.root]\n            for char in word:\n                nodes = [kid for node in nodes for kid in\n                         ([node[char]] if char in node else\n                          filter(None, node.values()) if char == '.' else [])]\n            return any(None in node for node in nodes)\n\nAnd a neat version where I append my end-marker to the word to simplify the final check:\n\n    class WordDictionary:\n    \n        def __init__(self):\n            self.root = {}\n        \n        def addWord(self, word):\n            node = self.root\n            for char in word:\n                node = node.setdefault(char, {})\n            node['$'] = None\n    \n        def search(self, word):\n            nodes = [self.root]\n            for char in word + '$':\n                nodes = [kid for node in nodes for kid in\n                         ([node[char]] if char in node else\n                          filter(None, node.values()) if char == '.' else [])]\n            return bool(nodes)
['Python']