There already was the question "Close programmatically all cell groups in Mathematica?"
Strangely the dualized question has not been posed yet: Is it possible to programmatically open all closed cell groups in a notebook?
The reason to rise it now is that using SelectionMove you can select a cell which is part of a closed group. If in the following example the last cell, which will be selected by proper SelectionMove commands, is part of a closed group, it stays invisible in the closed group, despite AutoScroll->True (contrary to the description):
This series of commands selects the last cell in a notebook:
nb = EvaluationNotebook[]; SelectionMove[nb, All, Notebook]
SelectionMove[nb, After, Cell]
SelectionMove[nb, Previous, Cell, AutoScroll -> True]
Which additional command will open the group in which the last cell is contained such that it becomes visible and is selected as the whole cell? (It might be part of several nested groups of cells!)
The clue are the two commands
However, one has to re-apply the method mentioned in my initial post once more after these two commands.
(I had this all in a notebook but I found no way to upload it... After copying all this to a notebook, set everything to manual grouping and then nest the cells from the last one one after the other with the next line above it and then close all subgroups.)
The attached notebook shows how it has to be done and it also contains a test example of deeply nested groups of cells at the very end to which the selection goes. However, a proof that this always works and never fails is still missing, since I have neither an "axiomatic" description of ExpandSelection nor of SelectionOpenAllGroups.
I wish there were more links "also see" in the Help system, especially whrer it is about FrontEnd-related functions.