<<PolylogTools`

<<TeXUtilities`

GatherCiTiList[expr_]:=Block[{temp=flatTensor[Expand[expr]]},temp=GatherBy[List@@CollectCiTi[temp,1],Last];
temp=CleanUp/@temp;
Return[temp];];
CleanUp[list_List]:={list[[1,2]],Total[list[[All,1]]]}
CollectCiTi[sum_Plus,a_]:=CollectCiTi[#,a]&/@sum;
CollectCiTi[a_. ct_CiTi,b_]:=CollectCiTi[a,ct b];
CollectCiTi[sum_Plus,a_]:=CollectCiTi[#,a]&/@sum;
CollectCiTi[a_. ct_CiTi,b_]:=CollectCiTi[a,ct b];
CleanUp[list_List]:={list[[1,2]],Total[list[[All,1]]]}
GatherCiTiList[expr_]:=Block[{temp=flatTensor[Expand[expr]]},temp=GatherBy[List@@CollectCiTi[temp,1],Last];
temp=CleanUp/@temp;
Return[temp];];

basgen[i_,n_] := Table[If[i==k,1,0], {k, 1, n}];

I41[x_,y_] := G[y, 0, 0,0, x, 1];
I32[x_,y_] := G[0,y, 0, 0,x, 1];

L5[x_] := -G[0,0,0,0, 1/x, 1];

(* --------- *)

candidate = (22/9) (I32i[x,y]--(1/2) (3 I41i[x,y]+I41i[x,(1/y)]+I41i[x,(x/y)]+I41i[x,(y/x)]-I41i[y,(x/y)]-I41i[y,(y/x)]))-((1/3) (-5) L5i[-(1/(-1+x))]-(23/18) L5i[(1/x)]+(20/3) L5i[(x/(-1+x))]-(1/12) L5i[(1/(((x-y))^2))]+(4/9) L5i[(((-1+x) x)/(((x-y))^2))]-(4/3) L5i[-(1/(x-y))]+2 L5i[(1/(x-y))]+(5/3) L5i[((-1+x)/(x-y))]-L5i[((-1+x)/(x (x-y)))]-(11/3) L5i[(x/(x-y))]-L5i[((x^2)/(x-y))]-(5/9) L5i[((x^2)/((-1+x) (x-y)))]+(1/3) L5i[-((x-y)/((-1+x) x))]-L5i[((x-y)/((-1+x) x))]-(5/9) L5i[((x (x-y))/(((-1+x))^2))]+(1/6) L5i[((((x-y))^2)/((((-1+x))^2) (x^2)))]-(1/9) L5i[((((x-y))^2)/((-1+x) x (((-1+y))^3)))]-(5/9) L5i[-((-1+x)/(((-1+y))^2))]-(1/6) L5i[((((-1+x))^2)/((x^2) (((-1+y))^2)))]-L5i[((x-y)/(((-1+y))^2))]+(5/9) L5i[((x-y)/(x (((-1+y))^2)))]-(5/3) L5i[-(((-1+x) (x-y))/(x (((-1+y))^2)))]-(1/48) L5i[((((x-y))^2)/((((-1+x))^2) (((-1+y))^2)))]-(5/18) L5i[((((x-y))^2)/(x (((-1+y))^2)))]+(11/3) L5i[-(1/(-1+y))]+(4/9) L5i[(1/((-1+x) (-1+y)))]+L5i[-(1/(x (-1+y)))]-L5i[-((-1+x)/(x (-1+y)))]-L5i[((((-1+x))^2)/(x (-1+y)))]+(1/9) L5i[(x/((((x-y))^2) (-1+y)))]+(1/9) L5i[((((-1+x))^3)/((x^2) (x-y) (-1+y)))]-(4/9) L5i[-(x/((x-y) (-1+y)))]-(7/3) L5i[-((x-y)/((-1+x) (-1+y)))]+2 L5i[((x-y)/((-1+x) (-1+y)))]-(4/9) L5i[-((x-y)/((x^2) (-1+y)))]-(4/3) L5i[-((x-y)/(x (-1+y)))]+(5/9) L5i[-((((x-y))^2)/((x^2) (-1+y)))]+L5i[-((((x-y))^2)/(x (-1+y)))]+L5i[-((((x-y))^2)/((-1+x) x (-1+y)))]-(1/9) L5i[-((((x-y))^3)/((-1+x) (x^3) (-1+y)))]-(5/9) L5i[-((-1+y)/(((-1+x))^2))]+(8/3) L5i[((-1+y)/(-1+x))]-(1/3) L5i[-((-1+y)/x)]+L5i[((-1+y)/x)]+L5i[((x (-1+y))/(-1+x))]-(4/3) L5i[-((x (-1+y))/((-1+x) (x-y)))]+2 L5i[((x (-1+y))/((-1+x) (x-y)))]-L5i[(((-1+x) x (-1+y))/(x-y))]-(1/48) L5i[((((-1+y))^2)/(x^2))]-(1/48) L5i[(((x^2) (((-1+y))^2))/((((-1+x))^2) (((x-y))^2)))]+(1/9) L5i[((x (((-1+y))^2))/((((-1+x))^3) (x-y)))]-(1/9) L5i[-((x (x-y))/((((-1+x))^2) (y^3)))]+(1/48) L5i[((x^2)/((((-1+x))^2) (y^2)))]+(1/9) L5i[((((-1+x))^2)/((x-y) (y^2)))]+(5/9) L5i[((x-y)/((-1+x) (y^2)))]+(5/9) L5i[-((((x-y))^2)/((-1+x) (y^2)))]-(1/6) L5i[((((x-y))^2)/((((-1+y))^2) (y^2)))]+(3/16) L5i[(((x^2) (((-1+y))^2))/((((x-y))^2) (y^2)))]-(1/9) L5i[-((x (((-1+y))^3))/((((-1+x))^3) (y^2)))]+(7/18) L5i[(1/y)]-(103/54) L5i[(1/(x y))]+(4/3) L5i[-(x/((-1+x) y))]-(4/9) L5i[((-1+x)/((x-y) y))]-(4/9) L5i[-((x-y)/((((-1+x))^2) y))]-(4/3) L5i[((x-y)/((-1+x) y))]+L5i[((((x-y))^2)/((-1+x) x y))]-(1/9) L5i[-((((x-y))^3)/((((-1+x))^3) x y))]+(1/9) L5i[(((-1+x) (x-y))/((((-1+y))^3) y))]+(5/27) L5i[((((x-y))^3)/(x (((-1+y))^3) y))]-L5i[((-1+x)/((-1+y) y))]-(1/9) L5i[-((-1+x)/((x^2) (-1+y) y))]+L5i[-((x-y)/((-1+y) y))]-2 L5i[((x-y)/((-1+y) y))]+(1/9) L5i[((((x-y))^2)/((((-1+x))^3) (-1+y) y))]-(5/3) L5i[-((((x-y))^2)/((-1+x) (-1+y) y))]-(1/9) L5i[-(((-1+x) (x^2) (-1+y))/((((x-y))^3) y))]-(1/3) L5i[-((x (-1+y))/((x-y) y))]+(7/3) L5i[-(y/(-1+x))]-3 L5i[(y/(-1+x))]-(157/54) L5i[(y/(x^2))]+(1/6) L5i[(y/x)]-L5i[-(y/((-1+x) x))]-L5i[(((-1+x) y)/x)]+L5i[((x y)/(-1+x))]+(1/9) L5i[-(((x^3) y)/((-1+x) (((x-y))^2)))]+(8/3) L5i[-(y/(x-y))]-2 L5i[-(((-1+x) y)/(x (x-y)))]+L5i[(((-1+x) y)/(x (x-y)))]-L5i[(((((-1+x))^2) y)/(x (x-y)))]-(5/3) L5i[-((x y)/(x-y))]+(2/3) L5i[((x y)/(x-y))]-L5i[-((x y)/((-1+x) (x-y)))]+(1/9) L5i[-(((x-y) y)/((-1+x) (x^3)))]-L5i[(((x-y) y)/x)]+L5i[(((x-y) y)/((-1+x) x))]+(5/27) L5i[-(((((-1+x))^3) y)/((x^2) (((-1+y))^3)))]+(1/9) L5i[(((((x-y))^2) y)/((-1+x) (((-1+y))^3)))]-(1/9) L5i[(((((x-y))^3) y)/((x^2) (((-1+y))^3)))]-(1/9) L5i[(y/((-1+x) x (((-1+y))^2)))]-(7/18) L5i[(((((-1+x))^2) y)/(x (((-1+y))^2)))]+(1/9) L5i[(((x-y) y)/((x^3) (((-1+y))^2)))]+L5i[-(((x-y) y)/(x (((-1+y))^2)))]+L5i[-(((-1+x) (x-y) y)/(x (((-1+y))^2)))]-(11/3) L5i[(y/(-1+y))]+L5i[-(y/((-1+x) (-1+y)))]+4 L5i[-(((-1+x) y)/(-1+y))]+(2/3) L5i[(((-1+x) y)/(-1+y))]-L5i[(((-1+x) y)/((x^2) (-1+y)))]-(5/9) L5i[(((((-1+x))^2) y)/((x^2) (-1+y)))]-(7/3) L5i[-(y/(x (-1+y)))]+3 L5i[(y/(x (-1+y)))]+(2/3) L5i[(((-1+x) y)/(x (-1+y)))]+(4/9) L5i[((x y)/((-1+x) (-1+y)))]-L5i[(((x-y) y)/((-1+x) (-1+y)))]+L5i[-(((x-y) y)/((x^2) (-1+y)))]+(4/9) L5i[(((-1+y) y)/((-1+x) x))]+L5i[-(((-1+y) y)/((-1+x) (x-y)))]+L5i[-(((-1+x) (-1+y) y)/(x-y))]-(1/9) L5i[((x (((-1+y))^2) y)/((-1+x) (((x-y))^3)))]+(1/48) L5i[((y^2)/(((-1+x))^2))]+(107/54) L5i[((y^2)/x)]-(1/6) L5i[(((((-1+x))^2) (y^2))/((x^2) (((x-y))^2)))]-(1/48) L5i[((y^2)/((x^2) (((-1+y))^2)))]+(4/9) L5i[(((-1+x) (y^2))/(x (((-1+y))^2)))]+(4/9) L5i[(((-1+x) (y^2))/((x^2) (-1+y)))]-L5i[((y^2)/(x (-1+y)))]+L5i[(((-1+x) (y^2))/(x (-1+y)))]-(1/9) L5i[-((x (y^2))/((((-1+x))^2) (-1+y)))]+(1/9) L5i[(((((-1+x))^3) (y^2))/((x^3) (x-y) (-1+y)))]+L5i[-(((-1+x) (y^2))/(x (x-y) (-1+y)))]-(1/9) L5i[-(((-1+y) (y^2))/((((-1+x))^2) x))]-(1/9) L5i[-(((-1+x) (x-y) (y^3))/((x^2) (((-1+y))^3)))]-(1/9) L5i[(((-1+x) (y^3))/((x^3) (((-1+y))^2)))]+(1/9) L5i[(((x-y) (y^3))/((x^2) (-1+y)))]+(1/9) L5i[((-1+y)/(x (((-x+y))^2)))]+(5/9) L5i[(((-1+y) y)/(((-x+y))^2))]+(2/3) L5i[((-1+y)/(-x+y))]-L5i[-((-1+y)/((-1+x) (-x+y)))]-(4/9) L5i[((-1+y)/(x (-x+y)))]-(4/9) L5i[-(y/((-1+x) (-x+y)))]-L5i[-(y/((-1+y) (-x+y)))]+(5/3) L5i[-(((-1+x) y)/((-1+y) (-x+y)))]-(2/3) L5i[(((-1+x) y)/((-1+y) (-x+y)))]-(5/3) L5i[-(((((-1+x))^2) y)/(x (-1+y) (-x+y)))]+(1/9) L5i[-((y^2)/((((-1+x))^2) (-x+y)))]-(4/9) L5i[((y^2)/((-1+y) (-x+y)))]+(1/9) L5i[-((y^3)/(x (((-1+y))^2) (-x+y)))]+L5i[-(((-1+y) (-x+y))/((((-1+x))^2) y))]-(4/9) L5i[((y (-x+y))/(((-1+y))^2))]-(5/18) L5i[((((-x+y))^2)/((((-1+x))^2) y))]-(1/9) L5i[(((-1+y) (((-x+y))^3))/((((-1+x))^2) (y^3)))]+(5/27) L5i[((x (((-x+y))^3))/((((-1+x))^3) (y^2)))]);

isSq[arg_] := #[[1,1]] == 1 && VectorQ[#[[2;;All,2]], EvenQ]&@FactorList[arg]

argSqrt[arg_] := (#[[1,1]]* Times@@MapThread[#1^(#2/2)&, Transpose[#[[2;;All]]]])&@FactorList[arg]

reduceL5sq[arg_] := If[isSq[arg], 2^4(L5i[argSqrt[arg]] + L5i[-argSqrt[arg]]), L5i[arg]];

L5sq[expr_] := expr/.L5i->reduceL5sq;

argumenttogenerators[arg_,generators_]:=Module[{factors,sign,vector,isgen,pos},(factors=FactorList[arg];
If[issubset[factors[[2;;All,1]],Join[generators,-generators]]==False,Return[{}]];
sign=factors[[1,1]];
vector=Table[0,{Length[generators]}];
For[i=2,i≤Length[factors],i++,isgen=MemberQ[generators,factors[[i,1]]];
If[isgen==False,sign*=(-1)^factors[[i,2]]];
pos=0;
If[isgen==True,pos=Position[generators,factors[[i,1]],1][[1,1]],pos=Position[generators,-factors[[i,1]],1][[1,1]]];
vector+=factors[[i,2]] basgen[pos,Length[generators]];];
Return[{sign,vector}];)];

makeargument[point_,generators_]:=Times@@(generators^point);

makesignedargument[{sgn_,pt_},generators_]:=sgn*makeargument[pt,generators];

makeL5can[arg_] := L5i[makesignedargument[argumenttogenerators[Sort[Factor[{arg, 1/arg}]][[1]], {x, y, x-y, 1-x, 1-y}],{x, y, x-y, 1-x, 1-y}]]

L5can[expr_] := expr/.L5i->makeL5can

L5inv[expr_] := expr/.L5i[arg_]:>L5i[Sort[Factor[{arg, 1/arg}]][[1]]]

i41s = (22/9) (I32i[x,y]+(1/2) (I41i[x,(1/y)]+I41i[x,(x/y)]+3 I41i[x,y]+I41i[x,(y/x)]-I41i[y,(x/y)]-I41i[y,(y/x)]));

li5s = (-(5/3) L5i[1-x]-(23/18) L5i[(1/x)]+(20/3) L5i[-((1-x)/x)]-(5/9) L5i[((1-x)/(((1-y))^2))]+(4/9) L5i[(1/((1-x) (1-y)))]+(8/3) L5i[((1-x)/(1-y))]-(5/9) L5i[((((1-x))^2)/(1-y))]+L5i[(1/(x (1-y)))]-(11/3) L5i[-((1-x)/(x (1-y)))]-(5/3) L5i[((1-x)/(x (1-y)))]-L5i[-((((1-x))^2)/(x (1-y)))]+(2/3) L5i[-(x/(1-y))]-(2/3) L5i[(x/(1-y))]+(11/3) L5i[1-y]+(4/9) L5i[-(((1-x) x)/(((x-y))^2))]+(1/9) L5i[-(x/((1-y) (((x-y))^2)))]-(8/3) L5i[-(1/(x-y))]+(2/3) L5i[(1/(x-y))]+(5/3) L5i[-((1-x)/(x-y))]-L5i[-((1-x)/(x (x-y)))]-(5/9) L5i[((((1-x))^2)/(x (x-y)))]-(11/3) L5i[(x/(x-y))]+(5/3) L5i[-(((1-x) x)/(x-y))]+3 L5i[(((1-x) x)/(x-y))]-L5i[((x^2)/(x-y))]-(5/9) L5i[-((x^2)/((1-x) (x-y)))]+(1/9) L5i[((((1-x))^3)/((x^2) (1-y) (x-y)))]-(4/9) L5i[(x/((1-y) (x-y)))]+(2/3) L5i[((1-y)/(x-y))]-L5i[((x-y)/(((1-y))^2))]+(5/9) L5i[((x-y)/(x (((1-y))^2)))]-(5/3) L5i[(((1-x) (x-y))/(x (((1-y))^2)))]+(1/9) L5i[-(((((1-x))^3) (x-y))/(x (((1-y))^2)))]-(8/3) L5i[-((x-y)/((1-x) (1-y)))]+(5/3) L5i[((x-y)/((1-x) (1-y)))]-L5i[(((1-x) (x-y))/(1-y))]-(4/9) L5i[((x-y)/((x^2) (1-y)))]-(4/3) L5i[((x-y)/(x (1-y)))]-L5i[((x-y)/((1-x) x (1-y)))]-(5/3) L5i[-(((1-x) (x-y))/(x (1-y)))]+(5/3) L5i[(((1-x) (x-y))/(x (1-y)))]-(4/9) L5i[((x (x-y))/(1-y))]-(1/9) L5i[((((x-y))^2)/((1-x) x (((1-y))^3)))]-(5/18) L5i[((((x-y))^2)/(x (((1-y))^2)))]+(5/9) L5i[((((x-y))^2)/((x^2) (1-y)))]+L5i[((((x-y))^2)/(x (1-y)))]+L5i[-((((x-y))^2)/((1-x) x (1-y)))]+(1/9) L5i[-((x (((x-y))^2))/(1-y))]-(1/9) L5i[-((((x-y))^3)/((1-x) (x^3) (1-y)))]-(1/9) L5i[-(((x^3) (((1-y))^2))/((1-x) (y^3)))]+(1/9) L5i[-(((x^2) (1-y))/((x-y) (y^3)))]-(1/9) L5i[-(((x^2) (((1-y))^3))/((1-x) (x-y) (y^3)))]-(1/9) L5i[-((x (x-y))/((((1-x))^2) (y^3)))]+(1/9) L5i[((x (((1-y))^2) (x-y))/(y^3))]-(1/9) L5i[(((1-y) (((x-y))^3))/((((1-x))^2) (y^3)))]+(107/54) L5i[(x/(y^2))]-(1/9) L5i[(((((1-x))^2) x)/((1-y) (y^2)))]-(1/9) L5i[(((((1-x))^2) (1-y))/(x (y^2)))]-L5i[-((x (1-y))/(y^2))]+L5i[((x (1-y))/((1-x) (y^2)))]+(4/9) L5i[(((x^2) (1-y))/((1-x) (y^2)))]+(4/9) L5i[-((x (((1-y))^2))/((1-x) (y^2)))]-(1/9) L5i[-((x (((1-y))^3))/((((1-x))^3) (y^2)))]+(1/9) L5i[((((1-x))^2)/((x-y) (y^2)))]+(5/9) L5i[-((x-y)/((1-x) (y^2)))]+(1/9) L5i[(((((1-x))^2) (x-y))/(y^2))]+L5i[-((x (1-y) (x-y))/((1-x) (y^2)))]+(1/9) L5i[(((x^3) (1-y) (x-y))/((((1-x))^3) (y^2)))]+(5/9) L5i[((((x-y))^2)/((1-x) (y^2)))]+(5/27) L5i[((x (((x-y))^3))/((((1-x))^3) (y^2)))]+(7/18) L5i[(1/y)]-(8/3) L5i[-((1-x)/y)]+(8/3) L5i[((1-x)/y)]-(103/54) L5i[(1/(x y))]+L5i[-((1-x)/(x y))]+(1/6) L5i[(x/y)]-(2/3) L5i[-(x/((1-x) y))]+(5/3) L5i[(x/((1-x) y))]-L5i[(((1-x) x)/y)]-(157/54) L5i[((x^2)/y)]-L5i[((1-x)/((1-y) y))]-(1/9) L5i[-((1-x)/((x^2) (1-y) y))]+(4/9) L5i[(((1-x) x)/((1-y) y))]-(11/3) L5i[-((1-y)/y)]+4 L5i[-((1-y)/((1-x) y))]+(2/3) L5i[((1-y)/((1-x) y))]+L5i[-(((1-x) (1-y))/y)]+(4/9) L5i[(((1-x) (1-y))/(x y))]+(8/3) L5i[-((x (1-y))/y)]-(8/3) L5i[((x (1-y))/y)]+(2/3) L5i[((x (1-y))/((1-x) y))]-(5/9) L5i[-(((x^2) (1-y))/((((1-x))^2) y))]-L5i[(((x^2) (1-y))/((1-x) y))]-(7/18) L5i[((x (((1-y))^2))/((((1-x))^2) y))]-(1/9) L5i[-(((1-x) x (((1-y))^2))/y)]+(5/27) L5i[-(((x^2) (((1-y))^3))/((((1-x))^3) y))]-(1/9) L5i[-(((1-x) (x^2) (1-y))/((((x-y))^3) y))]-(1/9) L5i[-(((x^2) (((1-y))^3))/((((x-y))^3) y))]+(1/9) L5i[(((1-x) (((1-y))^3))/((((x-y))^2) y))]-(4/9) L5i[-((1-x)/((x-y) y))]-L5i[(x/((x-y) y))]+L5i[-(((1-x) x)/((x-y) y))]+(1/9) L5i[(((1-x) (x^3))/((x-y) y))]-L5i[(((1-x) (1-y))/((x-y) y))]+3 L5i[-((x (1-y))/((x-y) y))]+(8/3) L5i[((x (1-y))/((x-y) y))]+L5i[(((x^2) (1-y))/((x-y) y))]-(4/9) L5i[-((((1-y))^2)/((x-y) y))]+L5i[-((x (((1-y))^2))/((x-y) y))]+L5i[((x (((1-y))^2))/((1-x) (x-y) y))]+(1/9) L5i[(((x^3) (((1-y))^2))/((x-y) y))]+(8/3) L5i[-((x-y)/y)]-(4/9) L5i[-((x-y)/((((1-x))^2) y))]-(4/3) L5i[-((x-y)/((1-x) y))]-(4/9) L5i[-(((1-x) (x-y))/y)]-(5/3) L5i[-((x-y)/(x y))]+(2/3) L5i[((x-y)/(x y))]-L5i[(((1-x) (x-y))/(x y))]-L5i[((x (x-y))/((((1-x))^2) y))]-(5/3) L5i[-((x (x-y))/((1-x) y))]-(14/3) L5i[((x (x-y))/((1-x) y))]+(1/9) L5i[(((1-x) (x-y))/((((1-y))^3) y))]-(14/3) L5i[-((x-y)/((1-y) y))]-(5/3) L5i[((x-y)/((1-y) y))]+L5i[-((x-y)/((1-x) (1-y) y))]+L5i[-(((1-x) (x-y))/((1-y) y))]+L5i[-(((1-y) (x-y))/((((1-x))^2) y))]-(2/3) L5i[-(((1-y) (x-y))/((1-x) y))]+(5/3) L5i[(((1-y) (x-y))/((1-x) y))]-(5/3) L5i[-((x (1-y) (x-y))/((((1-x))^2) y))]-(5/18) L5i[((((x-y))^2)/((((1-x))^2) y))]+(1/9) L5i[(((1-x) (((x-y))^2))/((x^3) y))]+L5i[-((((x-y))^2)/((1-x) x y))]+(1/9) L5i[((((x-y))^2)/((((1-x))^3) (1-y) y))]-(5/3) L5i[-((((x-y))^2)/((1-x) (1-y) y))]-(1/9) L5i[((((x-y))^3)/((((1-x))^3) x y))]+(5/27) L5i[-((((x-y))^3)/(x (((1-y))^3) y))]-(1/9) L5i[-(((1-x) (((x-y))^3))/(x (((1-y))^2) y))]+(5/9) L5i[-(((1-y) y)/(((x-y))^2))]-L5i[-(y/((1-y) (x-y)))]-(4/9) L5i[((y^2)/((1-y) (x-y)))]);

(i41s - li5s)/.{I32i->I32,I41i->I41,L5i->L5}//CreateTensor//sh//flatTensor//Expand

li5s//Cases[#, (c_:1)L5i[arg_]:>arg]&

Factor[1-%]

Position[%, -x+(x^2)-x y+(y^2)]

li5s[[%[[All,1]]]]

L5i[((((x-y))^2)/(x (1-y)))]-(1/9) L5i[(((((1-x))^2) x)/((1-y) (y^2)))]-(1/9) L5i[-(((1-x) (x^2) (1-y))/((((x-y))^3) y))]+L5i[-(((1-x) x)/((x-y) y))]+L5i[-(((1-x) (x-y))/((1-y) y))]-(1/9) L5i[-(((1-x) (((x-y))^3))/(x (((1-y))^2) y))]//TeXForm

L5i[((((x-y))^2)/(x (1-y)))]-(1/9) L5i[(((((1-x))^2) x)/((1-y) (y^2)))]-(1/9) L5i[-(((1-x) (x^2) (1-y))/((((x-y))^3) y))]+L5i[-(((1-x) x)/((x-y) y))]+L5i[-(((1-x) (x-y))/((1-y) y))]-(1/9) L5i[-(((1-x) (((x-y))^3))/(x (((1-y))^2) y))]/.L5i->L5//CreateTensor//sh//flatTensor//Expand

blah = %;

blah2 = Cases[blah, (c_:1)CiTi[w___]:>{w}];

blah2[[All,1]]//Union

blah2[[All,-1]]//Union

i41tensor = i41s/.{I41i->I41,I32i->I32}//CreateTensor//sh//flatTensor//Expand;

i41factors = Cases[i41tensor, (c_:1)CiTi[w___]:>{w}];

i41factors[[All,1]]//Union

i41factors[[All,5]]//Union

(* --------- *)

li5s//Length

Format[L5i[x_], TeXForm] := TeXVerbatim["\\left[" <> ToString@TeXForm[x] <> "\\right]\n"]
Format[I32i[x_,y_], TeXForm] := TeXVerbatim["I_{3,2}(" <> ToString[TeXForm[x]] <> ", " <> ToString[TeXForm[y]] <> ")"]
Format[I41i[x_,y_], TeXForm] := TeXVerbatim["I_{4,1}(" <> ToString[TeXForm[x]] <> ", " <> ToString[TeXForm[y]] <> ")"]

i41s//TeXForm

li5sfac = Abs[#[[1,2]]]*(Plus@@#/.L5icoeff[arg_,a_]:>a/Abs[a]L5i[arg])&/@(li5s/.(a_:1)L5i[arg_]:>L5icoeff[arg, a]//GatherBy[List@@#, Abs[#[[2]]]&]&)//Sort;
ColumnForm[%]

TeXForm[li5sfac]