private Map.Entry<Integer, Integer> traverseTree(String curIDRef, ArrayList<String> pathFromRoot) throws IDrefNotInSentenceException {
		String parentIdRef = "";
		Node curNode = getNode(curIDRef);
		if (curNode.getHeadIDref() == null && !curNode.isHeadChecked()) {
			Node newHead = calculateHeadWord(Arrays.asList(curIDRef));
			if (newHead != null)
				curNode.setHeadIDref(newHead.getId());
		}
		if (pathFromRoot.size() > 0)
			parentIdRef = pathFromRoot.get(pathFromRoot.size() - 1);
		curNode.addPathFromRoot(pathFromRoot);
		if (pathFromRoot.size() > 0)
			curNode.addParentIDref(parentIdRef);

		Map.Entry<Integer, Integer> lastFirstIDref;

		if (curNode.isTerminal()) {
			//pathFromRoot.add(curIDRef);
			lastFirstIDref = new AbstractMap.SimpleEntry<Integer, Integer>(Helper.getPosFromID(curIDRef), Helper.getPosFromID(curIDRef));
		} else {

			int firstPos = Integer.MAX_VALUE;
			int lastPos = 0;
			pathFromRoot.add(curIDRef);
			for (String childIdRef : curNode.getEdges().keySet()) {
				lastFirstIDref = traverseTree(childIdRef, (ArrayList<String>) pathFromRoot.clone());
				if (lastFirstIDref.getKey() < firstPos)
					firstPos = lastFirstIDref.getKey();
				if (lastFirstIDref.getValue() > lastPos)
					lastPos = lastFirstIDref.getValue();
			}

			curNode.setFirstWordPos(firstPos);
			curNode.setLastWordPos(lastPos);

			lastFirstIDref = new AbstractMap.SimpleEntry<Integer, Integer>(firstPos, lastPos);
		}
		return lastFirstIDref;
	}