Take a set of nodes and collapse them into a single function, replacing the given nodes with the new function node and returning it. A new function definition is made available as a new Function graph in the package.