def maybe_add_child(self, symbol):
    """Adds a new node for a given child symbol if not already in Trie."""
    if symbol in self.symbol_to_child:
      return self.symbol_to_child[symbol]
    else:
      node = TrieNode(symbol)
      self.symbol_to_child[symbol] = node
      return node
Adds a new node for a given child symbol if not already in Trie.
language/compgen/csl/cky/cfg_parser.py