private void addVariantsWithSameQualifier(@NotNull PsiElement element, @NotNull Set<String> result) {
    if (element instanceof GrReferenceExpression refExpr && element != myRefExpr && !PsiUtil.isLValue((GroovyPsiElement)element)) {
      final String refName = refExpr.getReferenceName();
      if (refName != null && !result.contains(refName) && myMatcher.prefixMatches(refName)) {
        final GrExpression hisQualifier = refExpr.getQualifierExpression();
        if (hisQualifier != null && myQualifier != null) {
          if (PsiEquivalenceUtil.areElementsEquivalent(hisQualifier, myQualifier)) {
            if (refExpr.resolve() == null) {
              result.add(refName);
            }
          }
        }
        else if (hisQualifier == null && myQualifier == null) {
          if (refExpr.resolve() == null) {
            result.add(refName);
          }
        }
      }
    }

    for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
      addVariantsWithSameQualifier(child, result);
    }
  }
private void addVariantsWithSameQualifier(@NotNull PsiElement element, @NotNull Set<String> result)