Detect if object data is associated with a scene in any way I'm making an addon for the NLA editor, and I need to know precisely which strips are selected in the NLA editor.

Unfortunately this means checking every single data object in the blend file, because there are 20 other data types with animation data to consider beside Objects - materials, nodetrees, armatures, worlds, etc...

The problem however is in telling whether or not one of these non-Objects are associated within the active scene, because if I have 5 scenes with NLA tracks in each one, I may have multiple NLA tracks selected in one scene's summary dopesheet,  but I just want to know the selected nla strips in the active scene's summary dopesheet (ignoring filters and such).

Simply put, I need to know which non-Objects (ie, material, armature, world, etc) are associated with a scene in any way.

Any ideas?
I looked at Blender's source code and realised it was quite an ordeal for the dopesheet to filter objects relevant to a context, so I gave up any hope of a simple solution and just went about doing a ersatz version of it in python.

It's a bit of a mess, but it works for detecting most non-objects (and objects) with animation data in a context:

https://gist.github.com/hedgehog90/634ea03acd2a1d87f99fbb06857e1956