private static String suggestReturnValue(@NotNull PsiParameterListOwner owner) {
    PsiType type;
    if (owner instanceof PsiMethod method) {
      type = method.getReturnType();
    }
    else if (owner instanceof PsiLambdaExpression lambda) {
      type = LambdaUtil.getFunctionalInterfaceReturnType(lambda);
    }
    else {
      return PsiKeyword.NULL; // normally shouldn't happen
    }

    // first try to find suitable local variable
    List<PsiVariable> variables = getDeclaredVariables(owner);
    for (PsiVariable variable : variables) {
      PsiType varType = variable.getType();
      if (varType.equals(type)) {
        return variable.getName();
      }
    }
    // then try to find a conversion of local variable to the required type
    for (PsiVariable variable : variables) {
      String conversion = getConversionToType(owner, variable, type, true);
      if (conversion != null) {
        return conversion;
      }
    }
    for (PsiVariable variable : variables) {
      String conversion = getConversionToType(owner, variable, type, false);
      if (conversion != null) {
        return conversion;
      }
    }
    return PsiTypesUtil.getDefaultValueOfType(type, true);
  }
private static String suggestReturnValue(@NotNull PsiParameterListOwner owner)