if(debug>0) {
if(debug>0 || mlistA.getEntryCount()>40) {
  public void mergeNode( BranchNode a, BranchNode b, ContentHandler ch ) throws SAXException {    if( (a != null && ((a.getBaseMatchType() | BranchNode.MATCH_CHILDREN) == 0 )) ||        (b != null && ((b.getBaseMatchType() | BranchNode.MATCH_CHILDREN) == 0 ) ) )      throw new RuntimeException("mergeNode: match type should be match children, otherwise the node should be null!");    MergeList mlistA = a != null ? makeMergeList( a ) : null;    MergeList mlistB = b != null ? makeMergeList( b ) : null;//    System.out.println("A = " + a ==null ? "-" : a.getContent().toString());//    System.out.println("B = " + b ==null ? "-" : b.getContent().toString());//    System.out.println("--------------------------");/*  if( mlistA.getEntryCount() > 30 )      debug=1;*/    if(debug>0) {    System.out.println("Merge A list");    if( mlistA != null )      mlistA.print();    else      System.out.println("--none--");    System.out.println("Merge B list");    if( mlistB != null )      mlistB.print();    else      System.out.println("--none--");    }    if( mlistA != null && mlistB != null ) {      mlistA = mergeLists( mlistA, mlistB ); // Merge lists      if(debug>0) {System.out.println("Merged list:");mlistA.print();}    } else if( mlistA == null ) {      mlistA = mlistB;      mlistB = null; // safety precaution    }    // Now, the merged list is in mlistA    // Handle updates & Recurse/*DEBUG    if( mlistA == null )      System.out.flush();*/    int _count1=0,_count2=mlistA.getEntryCount()-2;    for( int j=0;j<mlistA.getEntryCount();j++)      _count2+=mlistA.getEntry(j).getHangonCount();    for( Iterator i = mlistA.getExpandingIterator();i.hasNext();) {      _count1++;      HangonEntry me = (HangonEntry) i.next();      BranchNode n = me.getNode();//      BranchNode nPartner = n.getFirstPartner( BranchNode.MATCH_FULL );      // Merge contents of node and partner (but only if there's a partner)//-------------------// Table// n1    n2     Merge// any   null   n1// cont  cont   merge(n1,n2)// cont  str    n2// cont  full   merge(n1,n2)// str   str    FORCED content merge// str   full   n1 cont// full  full   merge(n1,n2)    BranchNode nPartner = null;    if( me instanceof MergeEntry )        nPartner = ((MergeEntry) me).getMergePartner();    else        nPartner = n.getFirstPartner(BranchNode.MATCH_FULL);/*    if( n.getContent().toString().indexOf("778l8") != -1 ) {      debug = 2;      System.out.println("???: " + n.getContent().toString() );    }*/    XMLNode mergedNode = null;    if( nPartner == null )      mergedNode = n.getContent();    else if( n.isMatch(BranchNode.MATCH_CONTENT) ) {      if( !nPartner.isMatch(BranchNode.MATCH_CONTENT) )        mergedNode = nPartner.getContent();      else        mergedNode = mergeNodeContent( n, nPartner );    } else {       // n doesn't match content      if( nPartner.isMatch(BranchNode.MATCH_CONTENT) )        mergedNode = n.getContent();      else // Neither matches content => forced merge        mergedNode = mergeNodeContent( n, nPartner );    }    if(debug>1) {      System.out.println("???:"+mergedNode.toString());    }//    XMLNode mergedNode = nPartner != null ? mergeNodeContent( n, nPartner ) : n.getContent();      if( mergedNode instanceof XMLTextNode ) {        XMLTextNode text = (XMLTextNode) mergedNode;        ch.characters(text.getText(),0,text.getText().length);      } else {        // It's an element node        XMLElementNode mergedElement = (XMLElementNode) mergedNode;        ch.startElement(mergedElement.getNamespaceURI(),mergedElement.getLocalName(),mergedElement.getQName(),mergedElement.getAttributes());        // Figure out partners for recurse        BranchNode ca = null, cb = null;        if( me instanceof MergeEntry && mlistB != null){ //: Earlier this cond, but it's not true- insert childs can have matches                                          // besides, all insert lists should be hangons only          // The node was merged, MUST have a partner in the list          MergeEntry me2 = (MergeEntry) me;/*          if( me2.getMergePartner() == null ) {            System.out.println("WARNING: I had to explicitly set mergePartner (should result only from sequencing conflict)");             mlistA.print();  //          debug = 1;            BranchNode nn = me2.getNode().getFirstPartner(BranchNode.MATCH_CHILDREN);            if( nn== null) {              nn = me2.getNode().getFirstPartner(BranchNode.MATCH_CONTENT);              if( nn == null ) {                System.out.println("!!!!SERIOUS ERROR: Node has no partner!");                throw new RuntimeException();              }            }            me2.setMergePartner(nn);          } */          if( (me2.getNode().getBaseMatchType() & BranchNode.MATCH_CHILDREN) == 0 ) {            ca=me2.getNode(); // Was content match, so we must use this one            if( (me2.getMergePartner().getBaseMatchType() & BranchNode.MATCH_CHILDREN) == 0 ) {              // CONFLICTCODE              System.out.println("CONFLICTW: I have to try to merge nonrelated childlists; nodes=");              try {                System.out.println(me2.getNode().getContent().toString());                System.out.println("  "+me2.getNode().getChild(0).getContent().toString());                System.out.println(me2.getMergePartner().getContent().toString());                System.out.println("  "+me2.getMergePartner().getChild(0).getContent().toString());              } catch (Exception e ) {} //Catch nullptrs              //System.out.println("CONFLICTW: Currently bailing out by arbitrarly choosing no 1");              cb=me2.getMergePartner();            } else              cb = null;          } else {            // me is structmatched            if( (me2.getMergePartner().getBaseMatchType() & BranchNode.MATCH_CHILDREN) == 0 ) {              ca=me2.getMergePartner();              cb=null;            } else {              ca=me2.getNode();              cb=me2.getMergePartner();            }          }        } else {          // me is a hangon entry          if( me.getNode().getBaseMatch() == null ) {            ca=me.getNode();            cb=null;          } else if ( (me.getNode().getBaseMatchType() & BranchNode.MATCH_CHILDREN) == 0 ) {            ca=me.getNode();            cb=null;          } else {            ca = me.getNode();            cb = me.getNode().getFirstPartner( BranchNode.MATCH_CHILDREN );            if( cb== null)              // Conflict processing can maybe mess this up by not deleting me              throw new RuntimeException("No struct partner, but it MUST exist here. Otherwise me would"+                                         "have been deleted whe merging the lists");          }        }/*        BranchNode ca = (n.getBaseMatch() == null)  || // if insert, or match children                        (n.getBaseMatchType() & BranchNode.MATCH_CHILDREN ) != 0 ? n : null;        BranchNode cb = n.getFirstPartner( BranchNode.MATCH_CHILDREN );*/        // Recurse!        mergeNode(ca,cb,ch);        ch.endElement(mergedElement.getNamespaceURI(),mergedElement.getLocalName(),mergedElement.getQName());      }    }      if(_count1!=_count2)        System.out.println("????COUNTS="+_count1+","+_count2);  }