SplitBy and Flatten