[BUGFIX] Prevent infinite loop

In some rare cases an unfortunate combination of dependencies defined in TS and viewhelpers would cause an infinite loop in ``AssetService::sortAssetsByDependency()``.