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) {
  //alert("here"+e)
myDiagram.startTransaction("reexpand");
var level = e;
myDiagram.findTreeRoots().each(function(g) {
  //console.log(g.child);
  g.collapseTree(level);
//expandGroups(g, 0, level);
})
myDiagram.commitTransaction("reexpand");
}

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 (it.next()) {
        var p = it.value;
        if (p instanceof go.Node && p.findTreeParentLink() === null) {
          root = p;
          break;
        }
      }
      if (root) {
        root.expandTree();
        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.