PsiElement (PsiElement element) { final PsiElement parent = element.getParent(); if (myOnQualifier) { if (parent instanceof PsiReferenceExpression ref) { return ref.getQualifierExpression(); } } else { if (parent instanceof PsiReferenceExpression) { final PsiElement grandParent = parent.getParent(); return grandParent instanceof PsiMethodCallExpression ? grandParent : parent; } } return super.getElementToRefactor(element); }