while (true) {
if (queue.isEmpty())
return null;
Path bestPath = queue.remove(0);
INode currentNode = bestPath.getLastEdge().getTargetNode();
if (goalTest.isGoal(currentNode))
return bestPath;
List<Path> newPaths = new ArrayList<Path>();
for (Edge edge : currentNode.generateSuccessors()) {
if (bestPath.containsNode(edge.getTargetNode()))
continue;
newPaths.add(new Path(bestPath, edge));
}
queueInserter.insert(queue, newPaths);