private void finishingTree(int stringIndex) {
		log.debug("Finishing tree");
		if(root.buildLink==null)
			return;
		SuffixTreeNode current = root.buildLink;
		SuffixTreeNode previous = root;
		while(current!=null){
			if(current.host == null){
				
			}
			else if(current.host.cut==current.host.end){
				log.debug("Working on the end '$' node");
				//TODO: find bug here
				current.host.addStringIndex(stringIndex);
			}
			else if(current.isLeaf==false && current.position == current.host.end){
				log.debug("Split ending nodes: "+current+" and "+current.host);
				//split(current,--current.position,stringIndex);
				current.position--;
				split(current,inputs.get(stringIndex).length()-1,stringIndex);
			}
			previous.buildLink = null;
			previous = current;
			current = current.buildLink;	
		}
	}