def GetAllUniqueNodes(root):
  """Return list of unique nodes in trie."""
  node_list = []
  def AddNodes(node, node_set):
    """Add unique nodes to node_list."""
    if node not in node_set:
      node_list.append(node)
      node_set.add(node)
      for _, child in sorted(node.children.iteritems()):
        AddNodes(child, node_set)
  AddNodes(root, set())
  return node_list