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

a =3; b=4;
roots = a + b;

I51[x_,y_]:=G[y,0,0,0,0,x,1];
L6[x_]:=-G[0,0,0,0,0,1/x,1];
N6[x_] := G[0, 0, 0, 0, 1, 1, x];

N6roots[arg_] := Sum[N6[arg]/.p->p[i], {i, 1, roots}];
Lip[arg_] := Sum[L6[arg]/.p->p[i], {i, 1, roots}];

(* I51roots[1,arg_]:= Sum[I51[1,arg]/.p->p[i], {i, 1, roots}];

pexp[expr_]:=expr/.{-1+p[i_]|1-p[i_]:>(Product[p[j],{j,1,roots}])^(1/b)/(p[i]^(a/b))}

out = -((N6roots[1-p])/a)+((N6roots[p])/b) + -(b-a)/(a^2)Lip[1-p]+-(-b+a)/(b^2)Lip[(1/p)]+1/(a + b)Lip[((-1+p)/p)]//CreateTensor//sh//pexp//ReduceTensorProduct//flatTensor//Expand

NotebookSave[];