Double Tree Collapse / Expand

Hi there again!

Hoping you can offer a pointer. I have a double tree diagram and I’d like to give the user the ability to expand / collapse. In real terms this means collapsing just the inner nodes leaving the root node and outer leaves. The diagram looks like this expanded:

After pressing the collapse button I’d want it to look like this:

The user can do this already by clicking on each of the leaf nodes but that’s a bit time consuming if the diagram is particularly large.

Any pointers on how to achieve do this. The button itself will likely be ouside of the GoJS diagram although I have no objections to it being part of the diagram if it makes it easier?

myDiagram.commit(diag => { diag.findTreeRoots().first().collapseTree(2); });

Or call Node.expandTree, or call expandTree and then collapseTree to make sure it’s “evenly” expanded.