private static boolean referencesTarget(@NotNull final PyExpression expression, @NotNull final PsiElement target) {
    final List<PsiElement> refs = new ArrayList<>();
    expression.accept(new PyRecursiveElementVisitor() {
      @Override
      public void visitPyReferenceExpression(@NotNull PyReferenceExpression node) {
        super.visitPyReferenceExpression(node);
        final PsiPolyVariantReference ref = node.getReference();
        if (ref.isReferenceTo(target)) {
          refs.add(node);
        }
      }
    });
    return !refs.isEmpty();
  }
private static boolean referencesTarget(@NotNull final PyExpression expression, @NotNull final PsiElement target)