private static void expandNode (final Problem problem, final Node node,
            final PriorityQueue<Node> frontier, final HashSet<Object> explored) {
        // Get all successors of the node.
        final List<Successor> successorSet =
                problem.getSuccessors(node.getState());
        for (Successor successor : successorSet) {
            if (!explored.contains(successor.getState())) {
                /* The successor has not been explored.
                 * Then check whether the successor is in the frontier. */
                Node nodeInFrontier = null;
                for (Node fNode : frontier) {
                    if (fNode.getState().equals(successor.getState())) {
                        // The successor has already existed in frontier.
                        nodeInFrontier = fNode;
                        break;
                    }
                }
                // Generate child node.
                final Node childNode =
                        generateChildNode(problem, node, successor);

                if (nodeInFrontier == null) {
                    // The successor is not in frontier nor explored, so add it.
                    frontier.add(childNode);
                } else if (Double.compare(childNode.getTotalCost(),
                        nodeInFrontier.getTotalCost()) < 0) {
                    /* The successor has lower cost than the same one in the
                     * frontier, so replace it. */
                    frontier.remove(nodeInFrontier);
                    frontier.add(childNode);
                }
            } // if (!explored.contains(successorState)) {
        } // for (Successor successor : successorSet) {
    }