Collection<NestingRule> (@NotNull final Collection<? extends NestingRule> rules, @NotNull final String fileName, final boolean parentNotChild) { final SmartList<NestingRule> result = new SmartList<>(); for (NestingRule rule : rules) { final Couple<Boolean> c = FileNestingBuilder.checkMatchingAsParentOrChild(rule, fileName); final boolean matchesParent = c.first; final boolean matchesChild = c.second; if (!matchesChild && !matchesParent) continue; if (matchesParent && parentNotChild) { result.add(rule); } if (matchesChild && !parentNotChild) { result.add(rule); } } return result; }