code: private static void flattenCategories(List<Category> flatList, List<Category> categories) {
      categories.forEach(category -> {
        flatList.add(category);
        List<Category> children = category.getChildren();
        if (children != null) {
          flattenCategories(flatList, children);
        }
      });
    }
docs: Goes through the list of parent categories and adds each category it visists to the flatList.
  
  @param flatList   list to which the categories for the flattened list should be added
  @param categories list of parent categories to go through recursively
  @implNote Internal helper method for {@link PreferencesFxUtils#flattenCategories(List)}.