Fiddle : http://jsfiddle.net/p35cobgx/3/
Below is my tree structure :
Node-1 (should store back reference of only Node because this is
last parent for Node-1)
Node-1-1(should store back reference of all parents i.e Node-1 and
Node because Node is the last parent for Node-1-1).
Use this condition for assigning the parent:
obj.parent = data.parent || null;