void (@NotNull ProgressIndicator original) { Set<ProgressIndicator> wrappedParents = null; for (ProgressIndicator i = original; i instanceof WrappedProgressIndicator; i = ((WrappedProgressIndicator)i).getOriginalProgressIndicator()) { if (wrappedParents == null) { wrappedParents = new HashSet<>(); } if (!wrappedParents.add(i)) { throw new IllegalArgumentException(i + " wraps itself"); } } }