PsiDirectory (PsiDirectory containingDirectory) { while (containingDirectory != null) { if (JavaDirectoryService.getInstance().isSourceRoot(containingDirectory)) { return containingDirectory; } containingDirectory = containingDirectory.getParentDirectory(); } return null; }