Let's use `Iterables` from Guava. The code will be much shorter