I am not sure I completely understand the question, but let me try to answer anyways.
First, select all nodes with no outgoing edges.
To do that, use "Tools" -> "Select Elements".
- On tab "General", make sure "Clear Selection First" and only "Clear Selection First" is enabled.
- Go to tab "Nodes" and enable "Use These Criteria".
Set option "Select" to "Outdegree" and specify "Minimal Degree" and "Maximal Degree" to be "0". - Click "Ok".
This will select all types of nodes with no outgoing edges.
The second step is to select to parent group nodes of the currently selected nodes.
Again, use "Tools" -> "Select Elements" for this purpose.
- On tab tab "General", enable "Act On Current Selection Only" and "Clear Selection First" both.
- On tab "Nodes", keep "Use These Criteria" enabled.
Set option "Select" to "Parents of Selected Nodes". - Click "Ok".
Now, the parent group nodes of all nodes with no outgoing edges should be selected.
Finally, close all the selected group nodes with "Grouping" -> "Close Group".