Terry Tao RMT book has the following formula for joint moment of freely independent random variables $X,Y$ in Section 2.5
$$\tau(XYXY)=\tau(X)^2\tau(Y^2)+\tau(X^2)\tau(Y)^2-\tau(X)^2\tau(Y)^2$$
Exercise 2.5.17 then asks to prove that this is possible for any joint moment. Is there an easy to describe algorithm for actually constructing such formulas? IE
How would I get $\tau(XYXYXY)$?