ThreeState (@NotNull Iterable<? extends ThreeState> states) { ThreeState result = null; for (ThreeState state : states) { if (state == UNSURE) { return UNSURE; } if (result == null) { result = state; } else if (result != state) { return UNSURE; } } if (result == null) throw new IllegalArgumentException("Argument should not be empty"); return result; }