getNextLevelForLevel = (level, capstoneStage = 1) => {
  const nextLevels = level.nextLevels || {}
  let nextLevel = []
  if (capstoneStage && level.isPlayedInStages) {
    nextLevel = Object.values(nextLevels).filter((n) => (n.conditions || {}).afterCapstoneStage === capstoneStage)
  } else {
    // Ensure that the next level is sorted by afterCapstoneStage
    nextLevel = Object.values(nextLevels).sort((a, b) => {
      const afterCapstoneStageA = a.conditions?.afterCapstoneStage ?? 0
      const afterCapstoneStageB = b.conditions?.afterCapstoneStage ?? 0

      return afterCapstoneStageA - afterCapstoneStageB
    })
  }
  return nextLevel[0] // assuming there can only be one next level for a given level and/or capstone stage
}
Gets the next level original ids for a given level
@param {Object} level - The level object.
@param {Object} level.nextLevels - The array of nextLevels for the given level.
@param {boolean|undefined} level.isPlayedInStages - True/false/undefined
@param {number} capstoneStage - Stage of capstone level for which we need the next level
@returns {Object} - Next level object containing 'Original' id and next level's stage.