Your comments

Open Tab outliner window

Press F12 to bring up developer console

Click the console tab and copy and paste the code below and hit enter

Found this on github, and can confirm it works.

treeView.treeModel.currentSession_rootNode.subnodes.forEach(node => node.setCollapsing(true))