/**
   * Adds a word to the tree. Also increments the successor value for each node
   *
   * @param aWord a word.
   */
  public void addWord(String aWord) {
    KeyValueNode<String, Integer> parent = root;

    for (int i = 0; i < aWord.length(); i++) {
      String subword = aWord.substring(0, i + 1);
      KeyValueNode<String, Integer> child = parent.getChild(subword);

      if (child != null) {
        if (!subword.equals(aWord)) {
          child.setValue(child.getValue() + 1);
        }
      } else {
        Integer value = 1;
        if (subword.equals(aWord)) {
          value = 0;
        }
        child = new KeyValueNode<String, Integer>(subword, value);
        parent.addChild(child);
      }

      parent = child;
    }
  }