public static boolean isPackage(@NotNull PsiFileSystemItem anchor, @Nullable PsiElement location) {
    return anchor instanceof PsiFile ? isPackage((PsiFile)anchor) :
           anchor instanceof PsiDirectory && isPackage((PsiDirectory)anchor, location);
  }
public static boolean isPackage(@NotNull PsiFileSystemItem anchor, @Nullable PsiElement location)