cleanupContextlessFormattingGap = (transaction, item) => {
  // iterate until item.right is null or content
  while (item && item.right && (item.right.deleted || !item.right.countable)) {
    item = item.right;
  }

  const attrs = new Set(); // iterate back until a content item is found

  while (item && (item.deleted || !item.countable)) {
    if (!item.deleted && item.content.constructor === ContentFormat) {
      const key =
      /** @type {ContentFormat} */
      item.content.key;

      if (attrs.has(key)) {
        item.delete(transaction);
      } else {
        attrs.add(key);
      }
    }

    item = item.left;
  }
}
@param {Transaction} transaction
@param {Item | null} item