function groupByDestructuring(variables, ignoreReadBeforeAssign) {
	const identifierMap = new Map();

	for (let i = 0; i < variables.length; ++i) {
		const variable = variables[i];
		const references = variable.references;
		const identifier = getIdentifierIfShouldBeConst(
			variable,
			ignoreReadBeforeAssign,
		);
		let prevId = null;

		for (let j = 0; j < references.length; ++j) {
			const reference = references[j];
			const id = reference.identifier;

			/*
			 * Avoid counting a reference twice or more for default values of
			 * destructuring.
			 */
			if (id === prevId) {
				continue;
			}
			prevId = id;

			// Add the identifier node into the destructuring group.
			const group = getDestructuringHost(reference);

			if (group) {
				if (identifierMap.has(group)) {
					identifierMap.get(group).push(identifier);
				} else {
					identifierMap.set(group, [identifier]);
				}
			}
		}
	}

	return identifierMap;
}
Groups by the VariableDeclarator/AssignmentExpression node that each
reference of given variables belongs to.
This is used to detect a mix of reassigned and never reassigned in a
destructuring.
@param {eslint-scope.Variable[]} variables Variables to group by destructuring.
@param {boolean} ignoreReadBeforeAssign
     The value of `ignoreReadBeforeAssign` option.
@returns {Map<ASTNode, ASTNode[]>} Grouped identifier nodes.