code: private void addVariableToFunction(Node function, @Nullable Node lhs, Node value) {
      checkState(value.getParent() == null);
      checkState(lhs == null || lhs.getParent() == null);
      Node block = NodeUtil.getFunctionBody(function);
      Node stmt;
      if (lhs != null) {
        stmt = NodeUtil.newVarNode(lhs, value);
      } else {
        stmt = IR.exprResult(value).useSourceInfoFrom(value);
      }
  
      // Insert the statement at the beginning of the function body, but after any
      // existing function declarations so that the tree stays normalized.
      Node insertionPoint = block.getFirstChild();
      while (insertionPoint != null && insertionPoint.isFunction()) {
        insertionPoint = insertionPoint.getNext();
      }
      if (insertionPoint == null) {
        block.addChildToBack(stmt);
      } else {
        block.addChildBefore(stmt, insertionPoint);
      }
      compiler.reportChangeToEnclosingScope(stmt);
    }
docs: Adds a variable to the top of a function block.
  @param function A function node.
  @param lhs The lhs expression.
  @param value The initial value of the variable.