private static int calculateNumBranches(GrIfStatement statement) {
    final GrStatement branch = statement.getElseBranch();
    if (branch == null) {
      return 1;
    }
    if (!(branch instanceof GrIfStatement)) {
      return 2;
    }
    return 1 + calculateNumBranches((GrIfStatement) branch);
  }
private static int calculateNumBranches(GrIfStatement statement)