Say you have a bunch of open groups or you’ve performed a search and you want to see all the file names but not the places where the search query is found.
You can select all with ⌘ + a
then hit the left arrow to close everything or the right arrow to open everything.