expose flatten API