PsiElement (@NotNull Module module, @NotNull PsiElement element) { if (element instanceof PsiFileSystemItem) { return element; } PsiFile containingFile = element.getContainingFile(); if (containingFile != null) { return element; } if (element instanceof PsiPackage) { return getPackageDirectory(module, (PsiPackage)element); } return null; }