private Node searchWord(NodeArray children,String word,int depth,Node parentNode){
  final int wordLength=word.length();
  final char c=word.charAt(depth);
  final int childrenLength=children.length;
  Node childNode=null;
  boolean found=false;
  for (int i=0; i < childrenLength; i++) {
    childNode=children.data[i];
    if (childNode.code == c) {
      found=true;
      break;
    }
  }
  if (!found) {
    childNode=new Node();
    childNode.code=c;
    childNode.parent=parentNode;
    children.add(childNode);
  }
  if (wordLength == depth + 1) {
    childNode.terminal=true;
    return childNode;
  }
  if (childNode.children == null) {
    childNode.children=new NodeArray();
  }
  return searchWord(childNode.children,word,depth + 1,childNode);
}

private Node searchWord ( NodeArray children , String word , int depth , Node parentNode ) { final int wordLength = word . length ( ) ; final char c = word . charAt ( depth ) ; final int childrenLength = children . length ; Node childNode = null ; boolean found = false ; for ( int i = 0 ; i < childrenLength ; i ++ ) { childNode = children . data [ i ] ; if ( childNode . code == c ) { found = true ; break ; } } if ( ! found ) { childNode = new Node ( ) ; childNode . code = c ; childNode . parent = parentNode ; children . add ( childNode ) ; } if ( wordLength == depth + 1 ) { childNode . terminal = true ; return childNode ; } if ( childNode . children == null ) { childNode . children = new NodeArray ( ) ; } return searchWord ( childNode . children , word , depth + 1 , childNode ) ; }
searches for the word and add the word if it does not exist .
