PsiVariable (@NotNull PsiVariable variable) { PsiElement scope = variable.getParent(); PsiElement[] children = scope.getChildren(); for (PsiElement child : children) { if (child instanceof PsiVariable) { if (child.equals(variable)) continue; if (Objects.equals(variable.getName(), ((PsiVariable)child).getName())) { return (PsiVariable)child; } } } return null; }