"Collapse All" and "Expand All" for hierarchically nested entities in list view

I have a generic entity type ‘page’ that is used a lot, and relates to itself through a field ‘parent page’.
In a list view, this is displayed through collapsable and expandable rows.

Over time, such list display becomes complex and opening closing parts of the hierarchy is tedious and gives massive cognitive overload.

Solution: add a button to Collapse all / expand all hierarchically related entities in the view.