What server are you using? There was a bug in Openfire (OF-572) related to this that was fixed in version 3.8.
The methods you are using should work, there is also the set/getCollection() method which is the inverse. It sets/gets the parent of the current node.