pwl.scalar[mainvid]._children = {};
is mainvid a variable containing a string? if you want to index the string "mainvid" you should use the syntax pwl.scalar["mainvid"]._children = {}; or pwl.scalar.mainvid._children = {}; Is that it?