private Node getNextToExpand() {
		Integer bestCost = null;

		Node next = null;

		for (int i = 0; i < nodes.length; i++)
			for (int j = 0; j < nodes[i].length; j++) {
				Node nd = nodes[i][j];
				if (nd != null && !nd.isVisited()) {
					if (nd.getCost() == null)
						continue;
					if (bestCost == null || bestCost > nd.getCost()) {
						bestCost = nd.getCost();
						next = nd;
					}
				}
			}
		return next;
	}