private static FoldRegion findTopLevelRegionInRange(Editor editor, RangeMarker range) {
    FoldRegion result = null;
    for (FoldRegion foldRegion : editor.getFoldingModel().getAllFoldRegions()) {
      if (foldRegion.isValid() && contains(range, foldRegion) && !contains(result, foldRegion)) {
        result = foldRegion;
      }
    }
    return result;
  }
private static FoldRegion findTopLevelRegionInRange(Editor editor, RangeMarker range)