public T root(final T id) {
        T current = id;
        T parent = ids.get(current);

        if (parent == null) {
            throw new NoSuchElementException("id: " + id.toString());
        }

        while (!parent.equals(current)) {
            // do the path splitting
            final T grandparent = ids.get(parent);
            ids.put(current, grandparent);

            current = parent;
            parent = grandparent;
        }
        return current;
    }
@throws NoSuchElementException if the parent of this node is null
streams/src/main/java/org/apache/kafka/streams/processor/internals/QuickUnion.java