Recursive unit flattening