findNextPosition = (transaction, pos, count) => {
  while (pos.right !== null && count > 0) {
    switch (pos.right.content.constructor) {
      case ContentFormat:
        if (!pos.right.deleted) {
          updateCurrentAttributes(pos.currentAttributes,
          /** @type {ContentFormat} */
          pos.right.content);
        }

        break;

      default:
        if (!pos.right.deleted) {
          if (count < pos.right.length) {
            // split right
            getItemCleanStart(transaction, createID(pos.right.id.client, pos.right.id.clock + count));
          }

          pos.index += pos.right.length;
          count -= pos.right.length;
        }

        break;
    }

    pos.left = pos.right;
    pos.right = pos.right.right; // pos.forward() - we don't forward because that would halve the performance because we already do the checks above
  }

  return pos;
}
@param {Transaction} transaction
@param {ItemTextListPosition} pos
@param {number} count steps to move forward
@return {ItemTextListPosition}

@private
@function