boolean (@NotNull U object, @NotNull Set<? super U> cache) { boolean isAccepted = false; Iterable<? extends U> children = getChildren(object); for (U child : children) { isAccepted |= computeAcceptCache(child, cache); } String name = myNamer.fun(object); isAccepted |= object == myRootObject || name != null && accept(name); if (isAccepted) { for (U child : children) { if (myNamer.fun(child) == null) cache.add(child); } cache.add(object); } return isAccepted; }