private static boolean[][] cleanTree(TreeNode[] tree, boolean[][] matrix) {
		System.out.println("Removing Self Dependencies Using Tree...");
		//Keeps track of which nodes have been checked for circular references
		boolean[] checked = new boolean[tree.length];
		
		//Keeps track of the path taken to get to a node
		Stack<TreeNode> path = new Stack<TreeNode>();
		for(int j=0; j < checked.length; j++) {
			if(!checked[j]) {
				path.add(tree[j]);
				while(path.size()!=0) {
					//Get the next step in the path
					TreeNode next = path.peek().getNext();
					if(next!=null) {
						//If the node is already in the path, sever the reference
						//This is/else loop balances the table
						if(path.contains(next)) {
							matrix[next.id][path.peek().id] = false;
						} else {
							//Only do this step if node has not been checked already
							if(checked[next.id])
								continue;
							//Add it to the current path
							path.push(next);
						}
					} else {
						//If we have reached the end of this branch, traverse back up
						checked[path.pop().id] = true;
					}
				}
			}
		}
		return matrix;
	}