How to get/track a list of subsites that were spawned from the current template

I want to get a list of subsites that were spawned from the current template - how could I get/track a subsite's source template?

Say I have two subsite templates, X & Y. Basically, I'm writing a plugin that needs to 1) know if it is inside a template site and 2) get a list of all other subsites that were built using the current template.
So, if run from inside the template X subsite, it would get a list of all other subsites that are also based upon template X. If the plugin were run from template Y, it would instead get a list of other sites that were based upon template Y.

My motivation is to build some tools to help propagate certain updates made to the original template off to its spawned subsites.