Error loading the parent of LeafNodes

I have a PEPService with a child LeafNode.

When I publish something to the leaf node, the subscribers of PEPService did not receive the event notification.

Debugging the code, I saw the leafNode.getParent() was returning null. This because the Node.getParent() method only returns the parent if the node.parentIdentifier attribute is not null.
Looking where it sets the parentIdentifier, I saw it was only in the constructor, where the parent is null for leafNodes. The parent is actually set in Node.changeParent().

However in Node.changeParent() only the node.parent attribute is set. The node.parentIdentifier is not set.

The fix I did was to set the parentIdentifier in Node.changeParent() as well.

The code

    protected void changeParent(CollectionNode newParent) {
        if (parent == newParent) {
            return;
        }

        if (parent != null) {
            // Remove this node from the current parent node
            parent.removeChildNode(this);
            parentIdentifier = null;
        }
        // Set the new parent of this node
        parent = newParent;
        if (parent != null) {
            // Add this node to the new parent node
            parent.addChildNode(this);
            parentIdentifier = parent.getUniqueIdentifier();
        }
        if (savedToDB) {
            PubSubPersistenceProviderManager.getInstance().getProvider().updateNode(this);
        }
    }