boolean (@Nullable final PsiFileSystemItem file, @Nullable VirtualFile stopParent, @NotNull final List<String> pathPrefix) { if (file == null) return false; final List<String> contextParts = new ArrayList<>(); PsiFileSystemItem parentFile = file; PsiFileSystemItem parent; while ((parent = parentFile.getParent()) != null && (stopParent == null || !Objects.equals(parent.getVirtualFile(), stopParent))) { if (parent.getName().length() > 0) contextParts.add(0, StringUtil.toLowerCase(parent.getName())); parentFile = parent; } final String path = StringUtil.join(contextParts, "/"); int nextIndex = 0; for (@NonNls final String s : pathPrefix) { if ((nextIndex = path.indexOf(StringUtil.toLowerCase(s), nextIndex)) == -1) return false; } return true; }