addMatching(n, baseMatch.getChild(0) );
addMatching(n, baseMatch.getChild(lastBaseChild) );
  private void matchSamePosUnmatched( BaseNode base, BranchNode branch) {    // Traverse in preorder -- to avoid building trees, just fixing levels where parents are matched    for( int i=0;i<branch.getChildCount();i++)      matchSamePosUnmatched(base,branch.getChild(i));    BaseNode baseMatch = branch.getBaseMatch(); // old  baseparent    if( baseMatch != null && baseMatch.getChildCount()>0 ) {      // Scan for unmapped nodes      for( int i=0;i<branch.getChildCount();i++) {        BranchNode n = branch.getChild(i);        BaseNode leftcand=null,rightcand=null;        int lastBaseChild = baseMatch.getChildCount()-1;        if( n.getBaseMatch() != null)          continue; // Mapped, all is well        // end points        if( i == 0 && !baseMatch.getChild(0).isMatched() ){          addMatching(n, baseMatch.getChild(0) );          continue;        } else if (i==branch.getChildCount()-1 && !baseMatch.getChild(lastBaseChild).isMatched()) {          addMatching(n, baseMatch.getChild(0) );          continue;        }        if( i > 0 ) {          // See if node preceding n is matched, and its right neighbour unmatched          // Base    xy     p=n's predecessor, x matches p and y unmatched          // Branch  pn        => match y and n          BaseNode x = branch.getChild(i-1).getBaseMatch();          if( x != null && x.hasRightSibling() && !((BaseNode) x.getRightSibling()).isMatched()) {            addMatching(n,(BaseNode) x.getRightSibling() );            continue;          }        }        if( i < branch.getChildCount()-1 ) {          // See if node succeeding n is matched, and its right neighbour unmatched          // Base    yx     p=n's succecessor, x matches p and y unmatched          // Branch  np        => match y and n          BaseNode x = branch.getChild(i+1).getBaseMatch();          if( x != null && x.hasLeftSibling() && !((BaseNode) x.getLeftSibling()).isMatched()) {            addMatching(n,(BaseNode) x.getLeftSibling() );            continue;          }        }      } // endfor    } // endif  }