code: function (root) {
      var children = root.children();
      for (var i = 0; i < children.length; i++) {
        var node = children[i];
        this.collapseBottomUp(node);
      }
      //If the root is a compound node to be collapsed then collapse it
      if (root.data("collapse") && root.children().length > 0) {
        this.collapseNode(root);
        root.removeData("collapse");
      }
    }
docs: collapse the nodes in bottom up order starting from the root