@Override
  @Nullable
  public PsiJavaDocumentedElement getContainer(final PsiElement element) {
    PsiJavaDocumentedElement container = super.getContainer(element);
    if (container == null || container instanceof PsiClass){
      return null;
    }
    while (container != null ) {
      final PsiClass parentClass = PsiTreeUtil.getParentOfType(container, PsiClass.class);
      if ((parentClass == null || container.getParent() instanceof PsiDeclarationStatement || container.getParent() instanceof PsiClass) &&
          container instanceof PsiClass && !(container instanceof PsiImplicitClass)){
        return container;
      }
      container = parentClass;
    }
    return null;
  }
@Override
  @Nullable
  public PsiJavaDocumentedElement getContainer(final PsiElement element)