It’s no Scripting solution but couldn’t the Layer Filter in the Layers Panel be used manually?
Otherwise you have to loop thoroug all the layers in the document and collect matching names. That is often slow, sometimes very slow.
Well, the Action Manager code approaches that (if I remeber correctly) you and Paul have presented seem fairly quick in contrast to DOM-approaches.