Pre-JS restructure. See extended desc for details

JS now internalizes a map of the state JSON string received for maximum
flexibility.

Map format:
key = obj.type + obj.id <---> value = {id: "id", type: "type", parentId:
"parentId", childrenIds: []}

After the restructuring, instead of naive DOM traversal, it will look up
hashed element ids and fetches data attrs and hierachial information via
document.getElementById(), traversing the internal map representation
instead. A lot of work ahead