private void inferNullabilityFromVariableReferences(@NotNull PsiVariable variable) {
            if (KotlinPluginModeProvider.Companion.isK1Mode()) {
                // Try not to break K1 nullability inference
                return;
            }

            SearchScope scope = getScope(variable);
            if (scope == null) return;

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

                final PsiElement refParent =
                        PsiTreeUtil.skipParentsOfType(referenceExpression, PsiParenthesizedExpression.class, PsiTypeCastExpression.class);

                processReference(variable, referenceExpression, refParent);

                if (isNullable(variable)) {
                    // We determined that the variable is nullable, so there is no need to check the rest of references.
                    // But if it is not-null, we keep going because we may find that it is nullable later, after all.
                    break;
                }
            }
        }
private void inferNullabilityFromVariableReferences(@NotNull PsiVariable variable)