private static @NotNull Map<TextRange, Boolean> removeZombieRegions(@NotNull FoldingModelEx foldingModel) {
    Map<TextRange, Boolean> zombieMap = null;
    List<FoldRegion> zombies = null;
    if (!(foldingModel instanceof FoldingModelImpl foldingModelImpl) ||
        (foldingModelImpl.getIsZombieRaised().compareAndSet(true, false))) {
      for (FoldRegion region : foldingModel.getAllFoldRegions()) {
        if (region.getUserData(ZOMBIE_REGION_KEY) != null) {
          if (zombieMap == null) {
            zombieMap = new HashMap<>();
            zombies = new ArrayList<>();
          }
          zombieMap.put(region.getTextRange(), region.isExpanded());
          zombies.add(region);
        }
      }
    }
    if (zombies != null) {
      for (FoldRegion region : zombies) {
        foldingModel.removeFoldRegion(region);
      }
    }
    return zombieMap != null ? zombieMap : Collections.emptyMap();
  }
private static @NotNull Map<TextRange, Boolean> removeZombieRegions(@NotNull FoldingModelEx foldingModel)