transformStatementList_(trees) {
    // If we need one or more machines, we want to aggregate the machines andany
    // free statements into one state machine.

    let groups = [];
    let newMachine;
    for (let i = 0; i < trees.length; i++) {
      if (trees[i].type === STATE_MACHINE) {
        groups.push(trees[i]);
      } else if (needsStateMachine(trees[i])) {
        newMachine = this.ensureTransformed_(trees[i]);
        groups.push(newMachine);
      } else {
        // Accumulate trees.
        let last = groups[groups.length - 1];
        if (!(last instanceof Array))
          groups.push(last = []);
        last.push(trees[i])
      }
    }

    if (groups.length === 1 && groups[0] instanceof Array)
      return null;

    let machine = null;

    for (let i = 0; i < groups.length; i++) {
      if (groups[i] instanceof Array) {
        newMachine = this.statementsToStateMachine_(groups[i]);
      } else {
        newMachine = groups[i];
      }
      if (i === 0)
        machine = newMachine;
      else
        machine = machine.append(newMachine);
    }

    return machine;
  }
@param {Array.<ParseTree>} trees This may already contain StateMachine
    trees.
@return {StateMachine}