func getOrCreatePackage(packages map[string]*types.Package, packageId string) *types.Package {
	if _, ok := packages[packageId]; ok {
		return packages[packageId]
	}

	targetPackage := types.Package{}
	targetPackage.PackageId = packageId
	targetPackage.Platforms = make(map[string]*types.Platform)

	return &targetPackage
}
func loadPackage(targetPackage *types.Package, folder string, logger i18n.Logger) error {
	packagePlatformTxt, err := props.SafeLoad(filepath.Join(folder, constants.FILE_PLATFORM_TXT), logger)
	if err != nil {
		return utils.WrapError(err)
	}
	targetPackage.Properties = utils.MergeMapsOfStrings(targetPackage.Properties, packagePlatformTxt)

	subfolders, err := utils.ReadDirFiltered(folder, utils.FilterDirs)
	if err != nil {
		return utils.WrapError(err)
	}

	subfolders = utils.FilterOutFoldersByNames(subfolders, constants.FOLDER_TOOLS)

	platforms := targetPackage.Platforms
	for _, subfolder := range subfolders {
		subfolderPath := filepath.Join(folder, subfolder.Name())
		platformId := subfolder.Name()

		_, err := os.Stat(filepath.Join(subfolderPath, constants.FILE_BOARDS_TXT))
		if err != nil && os.IsNotExist(err) {
			theOnlySubfolder, err := utils.TheOnlySubfolderOf(subfolderPath)
			if err != nil {
				return utils.WrapError(err)
			}

			if theOnlySubfolder != constants.EMPTY_STRING {
				subfolderPath = filepath.Join(subfolderPath, theOnlySubfolder)
			}
		}

		platform := getOrCreatePlatform(platforms, platformId)
		err = loadPlatform(platform, targetPackage.PackageId, subfolderPath, logger)
		if err != nil {
			return utils.WrapError(err)
		}
		platforms[platformId] = platform
	}

	return nil
}