code: static void redeclareVarsInsideBranch(Node branch) {
      Collection<Node> vars = getVarsDeclaredInBranch(branch);
      if (vars.isEmpty()) {
        return;
      }
  
      Node parent = getAddingRoot(branch);
      for (Node nameNode : vars) {
        Node var = IR.var(
            IR.name(nameNode.getString())
                .srcref(nameNode))
            .srcref(nameNode);
        copyNameAnnotations(nameNode, var.getFirstChild());
        parent.addChildToFront(var);
      }
    }
docs: Given a node tree, finds all the VAR declarations in that tree that are
  not in an inner scope. Then adds a new VAR node at the top of the current
  scope that redeclares them, if necessary.