giving all nodes the correct $ref by parent