function setCollapseStateAtLevel(foldingModel, foldLevel, doCollapse, blockedLineNumbers) {
    const filter = (region, level) => level === foldLevel && region.isCollapsed !== doCollapse && !blockedLineNumbers.some(line => region.containsLine(line));
    const toToggle = foldingModel.getRegionsInside(null, filter);
    foldingModel.toggleCollapseState(toToggle);
}
Folds or unfolds all regions that have a given level, except if they contain one of the blocked lines.
@param foldLevel level. Level == 1 is the top level
@param doCollapse Whether to collapse or expand