Can't think of a better name than `_groupby_leading_idxs` right now, but I'll add a docstring.