PsiNamedElement (@Nullable PsiElement element) { PsiNamedElement namedElement = (element instanceof PsiNamedElement) ? (PsiNamedElement)element : null; final PyClass containingClass = PyUtil.turnConstructorIntoClass(as(namedElement, PyFunction.class)); if (containingClass != null) { namedElement = containingClass; } else { namedElement = (PsiNamedElement)PyUtil.turnInitIntoDir(namedElement); } return namedElement; }