List<PyAssignmentStatement> (final @NotNull PsiElement self) { final List<PyAssignmentStatement> result = new ArrayList<>(); for (final PyAssignmentStatement statement : new PsiQuery<>(self).siblings(PyAssignmentStatement.class) .getElements()) { for (final PyQualifiedExpression targetExpression : new PsiQuery<PsiElement>(statement.getTargets()) .filter(new PsiQuery.PsiFilter<>(PyQualifiedExpression.class)) .getElements()) { final PyExpression qualifier = targetExpression.getQualifier(); if (qualifier == null) { continue; } final PsiReference qualifierReference = qualifier.getReference(); if (qualifierReference == null) { continue; } if (qualifierReference.isReferenceTo(self)) { result.add(statement); } } } return result; }