Tree Mapper tree Level Query

i m working on a diagram using tree mapper as base of my diagram

i need to know is there a way to make the trees in both groups to be opened to level 2 by default i cant seem to achieve that
i tried this

    function defaulTreeLvl(e) {
var level = e;
myDiagram.findTreeRoots().each(function(g) {
//expandGroups(g, 0, level);

but the findtreeroots give me the groups (leftside, rightside) instead of the item 0and the other one

Diagram.findTreeRoots in your case will find one of the Groups – it doesn’t know that you only care about Nodes within Groups.

I suggest you do something like:

myDiagram.commit(function(diag) {
  diag.findTopLevelGroups().each(function(g) {
      var root = null;
      var it = g.memberParts.iterator;
      while ( {
        var p = it.value;
        if (p instanceof go.Node && p.findTreeParentLink() === null) {
          root = p;
      if (root) {
        root.collapseTree(2);  // or 3 -- your requirements aren't clear
}, "collapse to two levels");

I haven’t tried this code, so please pardon me if there are some errors in it.