private boolean variableSometimesAssignedNull(@NotNull PsiVariable variable) {
        final PsiExpression initializer = variable.getInitializer();
        if (initializer != null && expressionIsSometimesNull(initializer)) {
            return true;
        }

        SearchScope scope = getScope(variable);
        if (scope == null) {
            return false;
        }

        final Query<PsiReference> references = ReferencesSearch.search(variable, scope);
        for (final PsiReference reference : references) {
            final PsiElement element = reference.getElement();
            if (!(element instanceof PsiReferenceExpression)) {
                continue;
            }
            final PsiElement parent = element.getParent();
            if (!(parent instanceof PsiAssignmentExpression assignment)) {
                continue;
            }

            if (assignment.getLExpression().equals(element) && expressionIsSometimesNull(assignment.getRExpression())) {
                return true;
            }
        }

        return false;
    }
private boolean variableSometimesAssignedNull(@NotNull PsiVariable variable)