Looks good, but as a side note,
Just looking at the code, What I am not sure about is that attributeData.id in the last line is used as before it is not assumed to be set. Also since both id and sid are set in newNode it would seem more consistent to have addToSidTree just take a newNode. I'll check that.