@Override
    public int compareTo(TraceNode rhs) {
        if (isLeaf() || rhs.isLeaf()) {
            if (isLeaf() && rhs.isLeaf()) {
                return note.compareTo(rhs.getNote());
            } else {
                return isLeaf() ? -1 : 1;
            }
        }
        if (children.size() != rhs.children.size()) {
            return children.size() < rhs.children.size() ? -1 : 1;
        }
        for (int i = 0; i < children.size(); ++i) {
            int cmp = children.get(i).compareTo(rhs.children.get(i));
            if (cmp != 0) {
                return cmp;
            }
        }
        return -1;
    }
Sort non-strict children recursively down the tree.

@return This, to allow chaining.
messagebus/src/main/java/com/yahoo/messagebus/TraceNode.java