PsiElement (PsiElement namedElement, PsiElement element) { if (element instanceof PyTargetExpression target) { final PyAssignmentStatement parent = PsiTreeUtil.getParentOfType(target, PyAssignmentStatement.class); if (parent != null && parent.getTargets().length == 1) { final PyExpression value = parent.getAssignedValue(); if (value != null) return value; } } else if (element.getParent() instanceof PyPrefixExpression) { return element.getParent(); } else if (element instanceof PyReferenceExpression) { return element; } return null; }