private String extractNextHead(String idRef) throws IDrefNotInSentenceException {

		Node node = sentence.getNode(idRef);
		String headIDref = null;
		String result = "HEAD";
		int readyCount = 0;
		int i = 0;
		while (headIDref == null && readyCount < node.getPathsFromRoot().size()) {
			i++;
			for (String[] path : node.getPathsFromRoot()) {
				if (path.length >= i) {
					String curHeadIDref;
					curHeadIDref = sentence.getNode(path[path.length - i]).getHeadIDref();
					if (curHeadIDref != null && !curHeadIDref.equals(sentence.getNode(idRef).getHeadIDref())) {
						headIDref = curHeadIDref;
					}
				} else {
					readyCount++;
				}
			}
		}

		if (headIDref != null) {
			result = sentence.getNode(headIDref).getAttributes().get("lemma");
			//System.out.print(idRef + ": " + result + "\t[");
			//for(String s: sentence.getNode(headIDref).getPathsFromRoot().get(0)){
			//	System.out.print(s+":"+sentence.getNode(s).getHeadIDref()+", ");
			//}
			//System.out.println("]");
		}
		return result;

	}