private static void mergeFlatStatements(SequenceStatement sequence) {

    while (true) {

      Statement next;
      Statement current = null;

      boolean found = false;

      for (int i = sequence.getStats().size() - 1; i >= 0; i--) {

        next = current;
        current = sequence.getStats().get(i);

        if (next != null && current.getExprents() != null && !current.getExprents().isEmpty()) {
          if (next.getExprents() != null) {
            next.getExprents().addAll(0, current.getExprents());
            current.getExprents().clear();
            found = true;
          }
          else {
            Statement first = getFirstExprentlist(next);
            if (first != null) {
              first.getExprents().addAll(0, current.getExprents());
              current.getExprents().clear();
              found = true;
            }
          }
        }
      }

      if (!found) {
        break;
      }
    }
  }