code: public void trimIds() {
      // typical case shortcut
      if (idToSymbol.containsKey(nextId - 1)) {
        return;
      }
      int max = -1;
      for (IntObjectCursor<String> cursor : idToSymbol) {
        max = Math.max(max, cursor.key);
      }
      nextId = max + 1;
    }
docs: If there are ids to reclaim at the end, then this will do this. Certainly be careful if you are
  doing operations where it is expected that the id mappings will be consistent across multiple FSTs
  such as in compose where you want the output of A to be equal to the input of B