Replaced flatten

Replaced flatten, with a recursive n deep version, to allow for any
depth, and as a nice side effect work for py3