public static @Nullable PsiPackage getContainingPackage(final @NotNull PsiElement element) {
    final PsiFile file = element.getContainingFile();
    if (file == null) return null;

    final PsiDirectory directory = file.getContainingDirectory();
    if (directory == null) return null;

    return JavaDirectoryService.getInstance().getPackage(directory);
  }
public static @Nullable PsiPackage getContainingPackage(final @NotNull PsiElement element)