public void buildHierarchy() {
		
		String[] keys;
		int	ancestorCount;
		YagoCategoryNodeOld node;
		ArrayList<YagoCategoryNodeOld> nodeArray;
		
		// order nodes by how many ancestors they have. Nodes with more ancestors MUST be at a lower level
		//   than those with less
		keys = this.nodeMap.keySet().toArray(new String[]{});
		for(int i = 0; i < keys.length; i++) {
			node = this.nodeMap.get(keys[i]);
			ancestorCount = node.getNumOfAncestors();
			nodeArray = this.buildMap.get(ancestorCount);
			if(nodeArray == null) {
				nodeArray = new ArrayList<YagoCategoryNodeOld>();
				this.buildMap.put(ancestorCount, nodeArray);
			}
			nodeArray.add(node);
		}
				
		Integer[] buildKeys;
		YagoCategoryNodeOld parent;
		YagoCategoryNodeOld ancestor;
		ArrayList<YagoCategoryNodeOld> ancestors;
		
		// Start from 0 and work our way up, establish the immediate parents. Those with 0 are top level classes
		//   and must be attached to root
		buildKeys = this.buildMap.keySet().toArray(new Integer[]{});
		
		for(int i = 0; i < buildKeys.length; i++) {
			nodeArray = this.buildMap.get(buildKeys[i]);
			System.out.println(nodeArray.size());
		}
		
		for(int i = 0; i < buildKeys.length; i++) {
			nodeArray = this.buildMap.get(buildKeys[i]);
			
			for(int j = 0; j < nodeArray.size(); j++) {
				node = nodeArray.get(j);
				ancestors = node.getAncestors();
				
				if(ancestors.size() == 0) {
					node.setParent(this.rootNode);
					this.rootNode.addChild(node);
				} else {
					parent = null;
					for(int k = 0; k < ancestors.size(); k++) {
						ancestor = ancestors.get(k);
						if(parent == null) {
							parent = ancestor;
						
						// find lowest-ranked ancestor - that's the immediate parent
						} else if (parent.getNumOfAncestors() > ancestor.getNumOfAncestors()){
							parent = ancestor;
						} // else do nothing
					}
					node.setParent(parent);
					parent.addChild(node);
				}
				
			}
			
		}
	}