code: private void replaceReferencesToThis(Node node, String name) {
      if (node.isFunction() && !node.isArrowFunction()) {
        // Functions (besides arrows) create a new binding for `this`.
        return;
      }
  
      for (Node child : node.children()) {
        if (child.isThis()) {
          Node newName = IR.name(name).useSourceInfoFrom(child).setJSType(child.getJSType());
          node.replaceChild(child, newName);
          compiler.reportChangeToEnclosingScope(newName);
        } else {
          replaceReferencesToThis(child, name);
        }
      }
    }
docs: Replaces references to "this" with references to name. Do not traverse function boundaries.