Reuse logic for iterable inference in comprehensions