code: function (node) {
      if (node._private.data.collapsedChildren == null) {
        node.data('position-before-collapse', {
          x: node.position().x,
          y: node.position().y
        });
  
        node.data('size-before-collapse', {
          w: node.outerWidth(),
          h: node.outerHeight()
        });
  
        var children = node.children();
  
        children.unselect();
        children.connectedEdges().unselect();
  
        node.trigger("expandcollapse.beforecollapse");
        
        this.barrowEdgesOfcollapsedChildren(node);
        this.removeChildren(node, node);
        node.addClass('cy-expand-collapse-collapsed-node');
  
        node.trigger("expandcollapse.aftercollapse");
        
        node.position(node.data('position-before-collapse'));
  
        //return the node to undo the operation
        return node;
      }
    }
docs: collapse the given node without performing end operation