Function flattenFrom