class ClassificationSummaryMerger extends AbstractElementMerger {

    @Override
    public void mergeNodes(List<Node> fromParents, Element toParent, Document toDocument) throws PDUStitchingException {
        final double[] weights = getWeights(fromParents);
        final Map<String, Double>[] percentagesPerPDU = getPercentagesFromParents(fromParents);
        List<String> elementNames = new ArrayList<>();
        List<Double> percentageValues = new ArrayList<>();
        for (int i = 0; i < fromParents.size(); i++) {
            for (Map.Entry<String, Double> percentage : percentagesPerPDU[i].entrySet()) {
                final String elementName = percentage.getKey();
                final int index = elementNames.indexOf(elementName);
                if (index >= 0) {
                    percentageValues.set(index, percentageValues.get(index) + weights[i] * percentage.getValue());
                } else {
                    elementNames.add(elementName);
                    percentageValues.add(weights[i] * percentage.getValue());
                }
            }
        }
        for (int i = 0; i < elementNames.size(); i++) {
            final Element newElement = toDocument.createElement(elementNames.get(i));
            newElement.setAttribute("percentage", percentageValues.get(i).toString());
            toParent.appendChild(newElement);
        }
    }

      ClassificationSummaryMerger(ImageSize[][] imageSizes);

}