@Test public void flattenWithInfiniteOuterStream() throws Exception {

  Stream<List<Integer>> infinite = Stream.iterate(
      ImmutableList.of(1), l -> l.stream().map(i -> i + 1).collect(toImmutableList()));
  Stream<Integer> flattened = MoreStreams.flatten(infinite.map(l -> l.stream()));
  assertThat(flattened.limit(5).collect(toList()))
      .containsExactly(1, 2, 3, 4, 5).inOrder();
}