public int compareTo(PathPattern<T> pattern) {
        int sizeDiff = elements.size() - pattern.elements.size();

        Iterator<Element> i = elements.iterator();
        Iterator<Element> j = pattern.elements.iterator();

        for (; ; ) {
            if (!i.hasNext() || !j.hasNext()) {
                return sizeDiff;
            }

            Element elemA = i.next();
            Element elemB = j.next();

            int result = elemA.priority() - elemB.priority();
            if (result != 0) {
                return result;
            }
        }
    }