code: function(tree) {
          var branches = tree.branches;
          for (var i in branches) {
            var subTree = branches[i];
            if (subTree.isOpen && !subTree.isLoading) {
              branches[i] = trimSubBranch(subTree);
            } else {
              branches[i] = {
                id: subTree.id,
              };
              if (subTree.label) {
                branches[i].label = subTree.label;
              }
            }
          }
          return tree;
        }
docs: Function to trim closed sub-branches from a tree