first implementation of flatten for Cons.