         var diff: [PiwigoAlbumData] = []
 
         // Look for sub-categories to remove
-        for category in categories {
-
-            // Keep the parent category
-            if category.albumId == categoryTapped.albumId {
-                continue
-            }
-
+        categories.filter({ $0.albumId != categoryTapped.albumId}).forEach { category in
             // Remove the sub-categories
             let upperCategories = category.upperCategories
             if upperCategories?.contains(String(format: "%ld", Int(categoryTapped.albumId))) ?? false {

        var subcategories: [PiwigoAlbumData] = []

        // Look for known requested sub-categories
        for category in allCategories {

            // Only add sub-categories of tapped category
            if ((category.parentAlbumId != categoryTapped.albumId) ||
                (category.albumId == currentCategory)) {
                continue
            }
            subcategories.append(category)
        }

        // Look for sub-categories which are already displayed
        var nberDisplayedSubCategories = 0
        for category in subcategories {

            for existingCat in categories {

                if category.albumId == existingCat.albumId {
                    nberDisplayedSubCategories += 1
                    break
                }
            }
        }

        // This test depends on the caching option loadAllCategoryInfo:

        var diff: [PiwigoAlbumData] = []

        // Look for categories which are not already displayed
        /// - Non-admin Community users can only upload in specific albums
        /// - Only add sub-categories of tapped category
        /// - Do not add the current category
        allCategories.filter({ Model.sharedInstance().hasAdminRights || $0.hasUploadRights })
            .filter({ $0.nearestUpperCategory == categoryTapped.albumId })
            .filter({ $0.albumId != currentCategory})
            .forEach { category in
            // Is this category already in displayed list?
            if !categories.contains(where: { $0.albumId == category.albumId }) {
                diff.append(category)
            }
        }

        // Build list of categories to be displayed
        diff.forEach { category in
            // Should we add sub-categories?
            if category.upperCategories.count > 0 {
                var indexOfParent = 0
                for existingCategory in categories {
                    if category.containsUpperCategory(existingCategory.albumId) {
                        categories.insert(category, at: indexOfParent + 1)
                        break
