private static @Nullable DeclarationInfo findExistingAnonymousClass(@NotNull PsiVariable variable,
                                                                        @Nullable PsiDeclarationStatement declarationStatement,
                                                                        boolean isBefore) {
      if (declarationStatement == null) return null;
      PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
      if (declaredElements.length != 1) return null;
      PsiLocalVariable localVariable = tryCast(declaredElements[0], PsiLocalVariable.class);
      if (localVariable == null) return null;
      String boxName = localVariable.getName();
      PsiNewExpression newExpression = tryCast(localVariable.getInitializer(), PsiNewExpression.class);
      if (newExpression == null) return null;
      PsiAnonymousClass anonymousClass = newExpression.getAnonymousClass();
      if (anonymousClass == null) return null;
      String variableName = variable.getName();
      if (variableName == null) return null;
      if (!TypeUtils.isJavaLangObject(anonymousClass.getBaseClassType())) return null;
      if (Arrays.stream(anonymousClass.getFields())
        .map(field -> field.getName())
        .anyMatch(name -> name.equals(variableName))) {
        return null;
      }
      return new DeclarationInfo(isBefore, localVariable, boxName);
    }
private static @Nullable DeclarationInfo findExistingAnonymousClass(@NotNull PsiVariable variable,
                                                                        @Nullable PsiDeclarationStatement declarationStatement,
                                                                        boolean isBefore)