Flatten a nested list. Python version.