addNode now assigns a unique id if it is given a null node id