void (final @NotNull PyReferenceExpression node) { final PsiPolyVariantReference reference = node.getReference(); if (reference.isReferenceTo(myElementToFind)) { myDependencyFound = true; return; } // TODO: This step is member-type specific. Move to MemberManagers? if (myElementToFind instanceof PyAssignmentStatement) { final PyExpression[] targets = ((PyAssignmentStatement)myElementToFind).getTargets(); if (targets.length != 1) { return; } final PyExpression expression = targets[0]; if (reference.isReferenceTo(expression)) { myDependencyFound = true; return; } if (node.getText().equals(expression.getText())) { // Check by name also myDependencyFound = true; } return; } final PsiElement declaration = reference.resolve(); myDependencyFound = PsiTreeUtil.findFirstParent(declaration, new PsiElementCondition()) != null; }