Merge Intervals Python