flatten.py