How to use hotkeys to toggle expansion and collapse in folder trees

Currently known order go expandbranch=toggle Can achieve the selected folder switch expanded and collapsed state, but does not apply to the folder tree, I would like to ask how to achieve this function, I try to combine commands

@if:Go TREECOLLAPSE=focus,second
Go TREEEXPAND=focus,all
Go TREECOLLAPSE=focus,second

It doesn't seem to work. Can anyone answer that?

I am afraid Go TREECOLLAPSE=focus,second won't create a lister state that can be probed with @if.

How to write the command to switch expansion and collapse of selected folder in folder tree