flatten nested lists in python
From http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python