flatten for n-nested lists

I can't claim credit for this, I snagged it from StackOverflow a long time ago and use it all of the time.