private static boolean hasConflictingVariableAfterwards(@Nullable PsiElement scope,
                                                          final @NotNull String name,
                                                          @NotNull Predicate<? super PsiVariable> canBeReused) {
    PsiElement run = scope;
    class Visitor extends JavaRecursiveElementWalkingVisitor {
      boolean hasConflict = false;

      @Override
      public void visitClass(final @NotNull PsiClass aClass) {}

      @Override
      public void visitVariable(@NotNull PsiVariable variable) {
        if (name.equals(variable.getName()) && !canBeReused.test(variable)) {
          hasConflict = true;
          stopWalking();
        }
        super.visitVariable(variable);
      }
    }
    Visitor visitor = new Visitor();
    while (run != null) {
      run.accept(visitor);
      if (visitor.hasConflict) return true;
      run = run.getNextSibling();
      if (scope instanceof PsiMethod || scope instanceof PsiForeachStatement) {//do not check next member for param name conflict
        break;
      }
    }
    return false;
  }
private static boolean hasConflictingVariableAfterwards(@Nullable PsiElement scope,
                                                          final @NotNull String name,
                                                          @NotNull Predicate<? super PsiVariable> canBeReused)