code: public void init() {
          surnameIndex.clear();
  
          final RootVisitor visitor = new RootVisitor();
          mRoot.accept(visitor);
          for (final Person person : visitor.getPersons()) {
              final String key = person.getString();
              // Surname for inclusion in the index.
              // This is the string by which the person will be indexed.
              final String indexName = person.getIndexName();
  
              if (!indexName.isEmpty()) {
                  final SortedMap<String, SortedSet<String>> names =
                          findNamesPerSurname(person.getSurname());
                  final SortedSet<String> ids = findIdsPerName(indexName, names);
                  ids.add(key);
              }
          }
      }
docs: Initialize the index from the root's objects.