Handle self-dependencies in _sort_decorated_packages