• Open/close all layer groups (folders) at the current level of hierarchy: Cmd-click the arrow next to the group - This is handy when you want to open/close, say, all the top-level groups without disturbing the open/closed state of any groups nested within them.
• Open/close all layer groups nested within the current one: Opt-click the arrow next to the group - This is nice when you want to open/shut a bunch of nested groups, without affecting any that lie outside the target group.
• Open/close all layer groups, period: Cmd-Opt-click the arrow next to a group
So, to keep things simple: when in doubt, Cmd-Opt-click a group’s arrow and you’ll collapse/expand all groups.
* On Windows please substitutes Ctrl for Cmd and Alt for Opt.