public Solution search(State state, int goalN) {
		SearchTreeNode init = createSearchTreeNode(state, null, 0, 0);
		queue.add(init);
		while (!queue.isEmpty()) {
			SearchTreeNode node = dequeue();
			if (visualize) {
				System.out.println(node.toString());
			}
			if (node.state.isGoal()) {
				return new Solution(node, problem.pathCost(node.state),
						numNodes);
			}
			// Expand node and add all its children to the queue.
			numNodes++;
			visitedStates.add(node.getState().toString());
			Collection<SearchTreeNode> childrenNodes = createSearchTreeNodes(
					node, node.state.getChildrenStates(problem));
			for (SearchTreeNode childNode : childrenNodes) {
				enqueue(childNode);
			}
		}
		return null;
	}