class ComponentUtils {

    public static Set<VersionedControllerService> getAncestorControllerServices(final String targetGroupId, final VersionedProcessGroup parentGroup) {
        final Set<VersionedControllerService> controllerServices = new LinkedHashSet<>();

        final boolean partOfDescendantChain = getAncestorControllerServices(targetGroupId, parentGroup, controllerServices);
        if (!partOfDescendantChain) {
            throw new IllegalStateException("The target process group is not a child of the starting group or any of its children");
        }

        return controllerServices;
    }

}