private void match( BaseNode base, BranchNode branch ) {
protected void match( BaseNode base, BranchNode branch ) {
  private void match( BaseNode base, BranchNode branch ) {//    System.out.println("Finding cand for " +branch.getContent().toString());    Vector candidates = findCandidates( base, branch ); // Find candidates for node branch in base    // Find best trees    //System.out.println("Finding best match");    int bestCount = 0;    CandidateEntry best = null;    Vector bestCandidates = new Vector();    for( Iterator i = candidates.iterator(); i.hasNext(); ) {      CandidateEntry candidate = (CandidateEntry) i.next();      // Bounus count of 1 for all candidates whose parents match the parent of the current node//     int initCount = candidate.candidate.parent != null && branch.parent != null//          && ((BranchNode) branch.parent).getBaseMatch() == candidate.candidate.parent ? 1 : 0;      int initCount = 0;      int thisCount = dfsMatch( candidate.candidate, branch, initCount, null );      if( thisCount == bestCount )        bestCandidates.add( candidate );      else if( thisCount > bestCount ) {        bestCount = thisCount;        bestCandidates.clear();        bestCandidates.add( candidate );      }    }    //System.out.println("Resolving amb");    // Resolve ambiguities if any exist...    if( bestCandidates.size() > 1 ) {      // Ambiguities - we need to find out which one is the best...      // First calc all missing left-right correlations      for( Iterator i = bestCandidates.iterator(); i.hasNext(); ) {        CandidateEntry candidate = (CandidateEntry) i.next();        if( candidate.leftRightDown < 0.0 ) {/*          System.out.println("left="+getDistanceOfLeft(candidate.candidate,branch));          System.out.println("right="+getDistanceOfRight(candidate.candidate,branch));          System.out.println("clist="+measure.childListDistance(candidate.candidate,branch));*/          candidate.leftRightDown = Math.min(            measure.childListDistance(candidate.candidate,branch),            Math.min( getDistanceOfRight(candidate.candidate,branch),              getDistanceOfLeft(candidate.candidate,branch)));        }      }      Collections.sort(bestCandidates,candlrdComp);      /*System.out.println("Best cands for " + branch.getContent().toString());      for( Iterator i = bestCandidates.iterator(); i.hasNext(); ) {        CandidateEntry ce = (CandidateEntry) i.next();        System.out.println( ce.distance + "," + ce.leftRightDown + ": " + ce.candidate.getContent().toString());      }*/    }    best = bestCandidates.isEmpty() ? null : (CandidateEntry) bestCandidates.elementAt(0);    if( best!=null && (bestCount == 1 &&      (Math.min(best.leftRightDown,best.distance) > 0.1 ||        best.candidate.content.getInfoSize() < COPY_THRESHOLD )))      best=null; //System.out.println("No candidate was very good, leaving unmatched" );    // Add matchings and find nodes below matching subtree    Vector stopNodes = new Vector();    if( best != null )      dfsMatch( best.candidate, branch, 0, stopNodes );    else {      // Unmatched      for( int i=0;i<branch.getChildCount();i++)        stopNodes.add(branch.getChild(i));    }    // Recurse    //System.out.println("---Recurse");    for( Iterator i=stopNodes.iterator();i.hasNext();)      match(base,(BranchNode) i.next());  }