[ty] Fix iteration over intersections with TypeVars whose bounds contain non-iterable types (#22117)
## Summary
When iterating over an intersection like `T & tuple[object, ...]` where
`T` is a `TypeVar` bounded by `tuple[int, ...] | int`, the iteration was
returning `object` instead of `int`. Now, when a `TypeVar` fails to
iterate normally, we check if it has a union bound, then extract the
iterable parts and use those for the result.
See:
https://github.com/astral-sh/ruff/pull/22115#issuecomment-3677967837