code: function byGroup() {
      var nodes = this.spawn();
      var edges = this.spawn();
  
      for (var i = 0; i < this.length; i++) {
        var ele = this[i];
  
        if (ele.isNode()) {
          nodes.merge(ele);
        } else {
          edges.merge(ele);
        }
      }
  
      return {
        nodes: nodes,
        edges: edges
      };
    }
docs: internal helper to get nodes and edges as separate collections with single iteration over elements