code: public Statement replace(Statement stat) {
      replacement = null;
      stat.visit(this);
      Statement result = replacement == null ? stat : replacement;
      replacement = null;
      return result;
    }
docs: Visits the specified statement. If the statement's visit method calls
  replaceVisitedMethodWith(), the statement will be replaced.