generalize chain to allow chain_from_iterable