https://github.com/elkarte/Elkarte/blob/0e19c550e246d216365391f197a8115e6ba8fc54/sources/admin/ManageThemes.controller.php#L1190
TBH, I'm not completely sure about what that query is trying to obtain... :-[
LOL, I can only imagine what that query tries to do.. From the code above and the two INNER JOINS it seems to be used for the "based_on" info and group it in the preview under the parent theme? Not sure though..
I'd name a function with this qeuery "determineParentTheme()"
O:-)
It's not only about the name of the function, but also to understand if it is possible to reuse something we already have around. like the loadOptionsInto (or something similar :P).