What about putting adding the group to the seen-list at the end, so the length does not need to be checked inside the loop? Also would save doing this in case thisOpType === getOpType(candidateOp) is true and the break is done.