List<DeferredOp> groupBys = OptimizerTools.getAll(outputs, GroupByKey.class);
int mscrId = 1;
Set<MSCR> mscrs = new HashSet<MSCR>();
// For all found GroupByKey blocks
for(DeferredOp gBK: groupBys) {
GroupByKey groupBy = (GroupByKey<?,?>)gBK;
// Gather all information needed for MSCR from this GBK
Set<PCollection<?>> inputs = new HashSet<PCollection<?>>();
Set<GroupByKey<?, ?>> outputChannels = new HashSet<GroupByKey<?, ?>>();
Set<Flatten<?>> unGroupedOutputChannels = new HashSet<Flatten<?>>();
Set<PCollection<?>> bypassChannels = new HashSet<PCollection<?>>();
Stack<LazyCollection<?>> toVisit = new Stack<LazyCollection<?>>();
Set<LazyCollection<?>> visited = new HashSet<LazyCollection<?>>();
LazyCollection<?> origin = (LazyCollection<?>)groupBy.getOrigin();
toVisit.push(origin);
outputChannels.add(groupBy);
while(!toVisit.isEmpty()) {
LazyCollection<?> current = toVisit.pop();
visited.add(current);