for( Iterator i = bestCandidates.iterator(); i.hasNext(); ) { CandidateEntry candidate = (CandidateEntry) i.next(); BranchNode left = (BranchNode) branch.getLeftSibling(); if( left != null && left.hasBaseMatch() && left.getBaseMatch() == candidate.candidate.getLeftSibling() ) { return candidate; } }
  protected CandidateEntry getBestCandidate( BaseNode base, BranchNode branch, Vector bestCandidates,    int bestCount ) {    CandidateEntry best=null;    //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" );    return best;  }