popCommonItems = (itemsSet, getKey, condition) => {
  /** @type {Map<string, Array<string>>} */
  const map = new Map();

  for (const item of itemsSet) {
    const key = getKey(item);
    if (key) {
      let list = map.get(key);
      if (list === undefined) {
        /** @type {Array<string>} */
        list = [];
        map.set(key, list);
      }
      list.push(item);
    }
  }

  /** @type {Array<Array<string>>} */
  const result = [];

  for (const list of map.values()) {
    if (condition(list)) {
      for (const item of list) {
        itemsSet.delete(item);
      }
      result.push(list);
    }
  }

  return result;
}
@param {Set<string>} itemsSet items set
@param {(str: string) => string | false} getKey get key function
@param {(str: Array<string>) => boolean} condition condition
@returns {Array<Array<string>>} list of common items