Search algorithm that returns the lowest cost path to one, of many possible goal nodes? I am working on a problem where I have a set of goal nodes of which some, all, or none of will appear in a search tree.

Is there a search algorithm which returns the lowest cost path to one goal node, when there are potentially many different goal nodes present in a tree, or failure?

This can obviously be solved by iterating through the set of goal nodes and applying a search algorithm on each of the goals and then comparing the paths to find the lowest cost path, but I would like know if there is a more elegant solution.

Thanks
Yes, any of the standard search algorithms will do that.

You seem to be under the misapprehension that search algorithms stop "when they reach node&nbsp;$x$." They don't: they stop when they reach a node with any property you tell them to use. That property could be "node&nbsp;$x$", or "any node in $x_1, \dots, x_k$", or "any node with score more than&nbsp;$10$" or any other condition you choose.