cluster(options = {}, refreshData = true) {
    if (options.joinCondition === undefined) {
      throw new Error(
        "Cannot call clusterByNodeData without a joinCondition function in the options."
      );
    }

    // check if the options object is fine, append if needed
    options = this._checkOptions(options);

    const childNodesObj = {};
    const childEdgesObj = {};

    // collect the nodes that will be in the cluster
    forEach(this.body.nodes, (node, nodeId) => {
      if (node.options && options.joinCondition(node.options) === true) {
        childNodesObj[nodeId] = node;

        // collect the edges that will be in the cluster
        forEach(node.edges, (edge) => {
          if (this.clusteredEdges[edge.id] === undefined) {
            childEdgesObj[edge.id] = edge;
          }
        });
      }
    });

    this._cluster(childNodesObj, childEdgesObj, options, refreshData);
  }
loop over all nodes, check if they adhere to the condition and cluster if needed.
@param {object} options
@param {boolean} [refreshData]