def METHOD_NAME(cls, list_op: Union[ListOp, PauliSumOp]) -> ListOp:
    """Given a ListOp, attempt to group into Abelian ListOps of the same type.
    Args:
        list_op: The Operator to group into Abelian groups
    Returns:
        The grouped Operator.
    Raises:
        OpflowError: If any of list_op's sub-ops is not ``PauliOp``.
    """
    if isinstance(list_op, ListOp):
        for op in list_op.oplist:
            if not isinstance(op, PauliOp):
                raise OpflowError(
                    "Cannot determine Abelian groups if any Operator in list_op is not "
                    f"`PauliOp`. E.g., {op} ({type(op)})"
                )
    edges = cls._anti_commutation_graph(list_op)
    nodes = range(len(list_op))
    graph = rx.PyGraph()
    graph.add_nodes_from(nodes)
    graph.add_edges_from_no_data(edges)
    # Keys in coloring_dict are nodes, values are colors
    coloring_dict = rx.graph_greedy_color(graph)
    groups = defaultdict(list)
    for idx, color in coloring_dict.items():
        groups[color].append(idx)
    if isinstance(list_op, PauliSumOp):
        primitive = list_op.primitive
        return SummedOp(
            [PauliSumOp(primitive[group], grouping_type="TPB") for group in groups.values()],
            coeff=list_op.coeff,
        )
    group_ops: List[ListOp] = [
        list_op.__class__([list_op[idx] for idx in group], abelian=True)
        for group in groups.values()
    ]
    if len(group_ops) == 1:
        return group_ops[0].mul(list_op.coeff)
    return list_op.__class__(group_ops, coeff=list_op.coeff)