class IfElseBreaker {
  ASTIfNode newIfNode;
  List<Object> remainingBody;

  public IfElseBreaker() {
    newIfNode = null;
    remainingBody = null;
  }

  public boolean isIfElseBreakingPossiblePatternOne(ASTIfElseNode node) {
    List<Object> ifBody = node.getIfBody();
    if (ifBody.size() != 1) {
      // we are only interested if size is one
      return false;
    }

    ASTNode onlyNode = (ASTNode) ifBody.get(0);
    boolean check = checkStmt(onlyNode, node);
    if (!check) {
      return false;
    }

    // breaking is possible
    // break and store
    newIfNode = new ASTIfNode(((ASTLabeledNode) node).get_Label(), node.get_Condition(), ifBody);
    remainingBody = node.getElseBody();

    return true;
  }

  public boolean isIfElseBreakingPossiblePatternTwo(ASTIfElseNode node) {
    List<Object> elseBody = node.getElseBody();
    if (elseBody.size() != 1) {
      // we are only interested if size is one
      return false;
    }

    ASTNode onlyNode = (ASTNode) elseBody.get(0);
    boolean check = checkStmt(onlyNode, node);
    if (!check) {
      return false;
    }
    // breaking is possible

    ASTCondition cond = node.get_Condition();
    // flip
    cond.flip();

    newIfNode = new ASTIfNode(((ASTLabeledNode) node).get_Label(), cond, elseBody);
    remainingBody = node.getIfBody();

    return true;
  }

  private boolean checkStmt(ASTNode onlyNode, ASTIfElseNode node) {<FILL_FUNCTION_BODY>}

  /*
   * The purpose of this method is to replace the ASTIfElseNode given by the var nodeNumber with the new ASTIfNode and to add
   * the remianing list of bodies after this ASTIfNode
   *
   * The new body is then returned;
   *
   */
  public List<Object> createNewBody(List<Object> oldSubBody, int nodeNumber) {
    if (newIfNode == null) {
      return null;
    }

    List<Object> newSubBody = new ArrayList<Object>();

    if (oldSubBody.size() <= nodeNumber) {
      // something is wrong since the oldSubBody has lesser nodes than nodeNumber
      return null;
    }

    Iterator<Object> oldIt = oldSubBody.iterator();
    int index = 0;
    while (index != nodeNumber) {
      newSubBody.add(oldIt.next());
      index++;
    }

    // check to see that the next is an ASTIfElseNode
    ASTNode temp = (ASTNode) oldIt.next();
    if (!(temp instanceof ASTIfElseNode)) {
      return null;
    }

    newSubBody.add(newIfNode);

    newSubBody.addAll(remainingBody);

    // copy any remaining nodes
    while (oldIt.hasNext()) {
      newSubBody.add(oldIt.next());
    }

    return newSubBody;
  }
}

    if (!(onlyNode instanceof ASTStatementSequenceNode)) {
      // only interested in StmtSeq nodes
      return false;
    }

    ASTStatementSequenceNode stmtNode = (ASTStatementSequenceNode) onlyNode;
    List<AugmentedStmt> statements = stmtNode.getStatements();
    if (statements.size() != 1) {
      // need one stmt only
      return false;
    }

    AugmentedStmt as = statements.get(0);
    Stmt stmt = as.get_Stmt();

    if (!(stmt instanceof DAbruptStmt)) {
      // interested in abrupt stmts only
      return false;
    }
    DAbruptStmt abStmt = (DAbruptStmt) stmt;
    if (!(abStmt.is_Break() || abStmt.is_Continue())) {
      // interested in breaks and continues only
      return false;
    }

    // make sure that the break is not that of the if
    // unliekly but good to check
    SETNodeLabel ifLabel = ((ASTLabeledNode) node).get_Label();

    if (ifLabel != null) {
      if (ifLabel.toString() != null) {
        if (abStmt.is_Break()) {
          String breakLabel = abStmt.getLabel().toString();
          if (breakLabel != null) {
            if (breakLabel.compareTo(ifLabel.toString()) == 0) {
              // is a break of this label
              return false;
            }
          }
        }
      }
    }
    return true;
  
<no_super_class>