boolean (PsiElement methodUsage, final PsiMethod methodToReplaceIn) { PsiElement parent = methodUsage.getParent(); while (parent != null) { if (parent.equals(methodToReplaceIn)) { return true; } parent = parent.getParent(); } return false; }