def sort_group(d, return_only_first=False):
    ''' Sort a dictionary of relative paths and cluster equal paths together at the same time '''
    d_sort = sort_dict_of_paths(d)
    base_elt = (-1, None)
    while (base_elt[1] is None and d_sort):
        base_elt = d_sort.pop(0)
    if base_elt[1] is None:
        return None
    else:
        lst = []
        lst.append([base_elt])
        if d_sort:
            for elt in d_sort:
                if elt[1] is not None:
                    if elt[1] == base_elt[1]:
                        lst[-1].append(elt)
                    else:
                        if return_only_first: break
                        lst.append([elt])
                        base_elt = elt
        return lst