@@ -0,0 +1,1036 @@
+package refdiff.core.diff;%0D%0A%0D%0Aimport refdiff.core.rast.RastNode;%0D%0A%0D%0Apublic class PotentialMatch implements Comparable%3CPotentialMatch%3E %7B%0D%0A%09%0D%0A%09private final RastNode nodeBefore;%0D%0A%09private final RastNode nodeAfter;%0D%0A%09private final int maxDepth;%0D%0A%09private final double score;%0D%0A%09%0D%0A%09public PotentialMatch(RastNode nodeBefore, RastNode nodeAfter, int maxDepth, double score) %7B%0D%0A%09%09this.nodeBefore = nodeBefore;%0D%0A%09%09this.nodeAfter = nodeAfter;%0D%0A%09%09this.maxDepth = maxDepth;%0D%0A%09%09this.score = score;%0D%0A%09%7D%0D%0A%09%0D%0A%09public RastNode getNodeBefore() %7B%0D%0A%09%09return nodeBefore;%0D%0A%09%7D%0D%0A%09%0D%0A%09public RastNode getNodeAfter() %7B%0D%0A%09%09return nodeAfter;%0D%0A%09%7D%0D%0A%09%0D%0A%09public double getScore() %7B%0D%0A%09%09return score;%0D%0A%09%7D%0D%0A%09%0D%0A%09public double getMaxDepth() %7B%0D%0A%09%09return score;%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public String toString() %7B%0D%0A%09%09return String.format(%22(%25s, %25s)%22, this.nodeBefore, this.nodeAfter);%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public int compareTo(PotentialMatch o) %7B%0D%0A%09%09int c1 = Integer.compare(maxDepth, o.maxDepth);%0D%0A%09%09int c2 = -Double.compare(score, o.score);%0D%0A%09%09return c1 != 0 ? c1 : c2;%0D%0A%09%7D%0D%0A%7D%0D%0A

Use node depth to sort candidates