code: private void checkInvariants() {
          for (int i = 0; i < tokens.size(); i++) {
              Token token = tokens.get(i);
  
              Preconditions.checkArgument(token.getID() == i + 1,
                      String.format("Tokens should be numbered consecutively, starting at 1: %s", token));
  
              checkHead(token, token.getHead());
              checkHead(token, token.getPHead());
          }
      }
docs: Check invariants: tokens should number from 1..n, heads should point to
  a token or 0.