PsiJavaDocumentedElement (final PsiElement element) { PsiJavaDocumentedElement container = super.getContainer(element); if (container == null) { return null; } while (container != null) { final PsiClass parentClass = PsiTreeUtil.getParentOfType(container, PsiClass.class); if (parentClass == null && container instanceof PsiClass) { return container; } container = parentClass; } return null; }