Add recursive flatten and simple flatten