<<PolylogTools`

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];

I14[x_,y_] := G[ 0, 0,0,y, x, 1];
I23[x_,y_] := G[0,0,y, 0,x, 1];

L1[x_] := -G[1/x, 1];
L2[x_] := -G[0, 1/x, 1];
L3[x_] := -G[0, 0,1/x, 1];
L4[x_] := -G[0, 0, 0,1/x, 1];
L5[x_] := -G[0,0,0,0, 1/x, 1];

cr[{a_,b_,c_,d_}]:=((a-c)/(a-d))/((b-c)/(b-d))
cr[{a_,b_,c_}]:=((a-c)/(b-c))

cr[{Inf,b_,c_,d_}]:=cr[{d,c,b}]
cr[{a_,Inf,c_,d_}]:=cr[{c,d,a}]
cr[{a_,b_,Inf,d_}]:=cr[{b,a,d}]
cr[{a_,b_,c_,Inf}]:=cr[{a,b,c}]

cr[{a_,b_,c_,d_,e_}] := Sequence[cr[{a,b,c,d}],cr[{a,b,c,e}]];

I41[cr[{a,b,c,d,e}]] + I14[cr[{b,a,d,c,e}]] + L5[cr[{b,a,c,d}]]//CreateTensor//sh//flatTensor//Expand

I32[cr[{a,b,c,d,e}]] + I23[cr[{b,a,d,c,e}]] + L5[cr[{b,a,c,d}]]//CreateTensor//sh//flatTensor//Expand