Self (final StringPattern namePattern) { return with(new PatternCondition<T>("withParentDirectoryName") { @Override public boolean accepts(final @NotNull T t, final ProcessingContext context) { PsiDirectory directory = t.getContainingDirectory(); return directory != null && namePattern.accepts(directory.getName(), context); } }); }