Get occurrences for loops with 'break'/'continue' statements

The above logic seems very similar to aggregateBreakContinues above. If it's not too hard, can you consolidate it? It might be hard