code: def make_automaton(self):
  		
  
  		queue = deque()
  
  		# 1.
  		for i in range(256):
  			c = chr(i)
  			if c in self.root.children:
  				node = self.root.children[c]
  				node.fail = self.root	# f(s) = 0
  				queue.append(node)
  			else:
  				self.root.children[c] = self.root
  
  		# 2.
  		while queue:
  			r = queue.popleft()
  			for node in r.children.values():
  				queue.append(node)
  				state = r.fail
  				while node.char not in state.children:
  						state = state.fail
  
  				node.fail = state.children.get(node.char, self.root)
docs: Converts trie to Aho-Corasick automaton.