As I reported in https://sourceforge.net/p/mediatomb/discussion/440751/thread/8c4b590d/#3531 , there's a behaviour difference between the builtin and js methods of creating a hierarchy, to wit the object container classes from Javascript are beign dropped.
I did a bit of digging, and found a one line coding error causing the problem. A patch is attached.
The error was that the object class passed to js_addCdsObject was being assigned twice, and the seond assignment was after the extracted parameter had been freed. This is important because it was likely only showing up in debug builds such as I was running; release libraries often don't clear an object upon free, so this flaw might not have caused an actual problem on many release builds.
Just discovered that this is an exact duplicate of https://sourceforge.net/p/mediatomb/bugs/116/