local i, category;
for i=1,GetNumTrainerServices() do
_ , _, category = GetTrainerServiceInfo(i);
if (category == nil) then
break; -- GetNumTrainerServices() does not check if you're talking to a trainer or not.
end
if (category == "header") then
CollapseTrainerSkillLine(i);
end
end