def GetAllAcceptSequences(root):
  """Return all the byte sequences that are accepted by a trie.

  Args:
    root: the root of the trie to generate accepting sequences for.
  Returns:
    sequences: a list of tuples containing information about accepts.
    Each tuple is a pair of AcceptInfo and a list of the bytes that is accepted.
  """
  accept_sequences = []
  def AddAcceptSequences(node, context):
    if node.accept_info is None and not node.children:
      raise ValueError('Node has no children but is not accepting', context)
    if node.accept_info is not None:
      accept_sequences.append((node.accept_info, context))
    for key, value in sorted(node.children.iteritems()):
      AddAcceptSequences(value, context + [key])
  AddAcceptSequences(root, [])
  return accept_sequences