Suppose my expressions are given as a combinations of non-commutative products, i.e., $2 X**Y**Z + 3 Y**Z**X$, I want to make this as commutative product and get $5 X**Y**Z$. And want similar things for higher length operations, i.e., $X**Y**Z**W**K$.
I have a long list of inputs with $X**Y**Z**\cdots$ and my first trial was just replacing $X**Y \mapsto X*Y$ or $Y**X \mapsto X**Y$ but i realized it did not worked well and i need a lots of expressions for practical use.