public SpriteGeneratorSearchNode SearchStep(SpriteGeneratorSearchProblem problem) { // If the fringe is empty, return null to indicate that no solution was found if (fringe.Empty) { return(null); } // Select the next node var node = fringe.Remove(); // If the node is a solution, then we're done! Otherwise expand the node and add to the queue if (!problem.IsGoal(node.State)) { AddNodes(fringe, node, problem); } // Return the node that we selected to the caller return(node); }