class AlternativeViolationPredicate {

    public static Predicate<Violation> firstAlternativeViolation() {
        Set<Node> coveredNodes = new HashSet<>();
        return violation -> {
            Set<Node> mappedTargetNodes = violation.getOverlap().getMappedTargetNodes().stream()
                    .filter(node -> node instanceof MethodCallNode)
                    .collect(Collectors.toSet());
            if (mappedTargetNodes.stream().anyMatch(coveredNodes::contains)) {
                return false;
            } else {
                coveredNodes.addAll(mappedTargetNodes);
                return true;
            }
        };
    }

}