code: private Collection<DetArcWork> groupByInputLabel(final DetStateTuple detStateTuple) {
      Map<Integer, DetArcWork> inputLabelToWork = Maps.newHashMap();
      for (DetElement detElement : detStateTuple.getElements()) {
        State inputState = getInputStateForId(detElement.getInputStateId());
        for (Arc inputArc : inputState.getArcs()) {
  
          UnionWeight<GallicWeight> inputArcAsUnion = UnionWeight.createSingle(
            GallicWeight.createSingleLabel(inputArc.getOlabel(), inputArc.getWeight())
          );
          DetElement pendingElement = new DetElement(inputArc.getNextState().getId(),
            this.unionSemiring.times(detElement.getResidual(), inputArcAsUnion));
  
          DetArcWork work = inputLabelToWork.computeIfAbsent(inputArc.getIlabel(),
            iLabel -> new DetArcWork(iLabel, this.unionSemiring.zero()));
          work.pendingElements.add(pendingElement);
        }
      }
      return inputLabelToWork.values();
    }
docs: input states in the residset, and just create pending (possibly duplicate) input residuals for the target states