expose flatten method as top-level function