The top-most groups are the categories. If you need to have multiple versions at different depth, use the same name on the linked layers ('__\d+_$'is removed for comparisons, '_x3(\d)_(\d+)?(_\d+)$' is replaed by '$1$2', '_x5F' is replaced by underscore).
input.replace(/_x([0-9A-Za-z]+)_/g, s => String.fromCodePoint(parseInt(s.substring(2, s.length - 1), 16))).replace(/_/g, " ");
To allow more than one of a category, add '+' to the name. (Accessories+)
Colors are identified automatically? Or list of colors / non-colors.Example: Hat Biker [=helmet] Knight [=helmet] Stetson [=hat] Tiara Hair__1_ Mohawk [~helmet&~hat] Fancy__3_ Eyes Sharp Closed Hair Fancy [helmet]__1_ Fancy [~helmet] Head Round Hair__2_ Fancy [helmet]__2_ Fancy [~helmet]__2_ Long [helmet] Long [~helmet] Randomize