Loading file into existing node

Greetings slicer experts,

I was wondering is someone could help me solving my little problem.
What I would like to do is loading a file directly into an existing node.

In this moment to load a file (.nii for example) the instruction I use is:
_, self.upNode = slicer.util.loadVolume(filepath, returnNode=True)

This creates a new node (upNode), with the same name as the filename, where I can explore my image.

Would it be possible to load filepath directly into an already existing node (a vtkMRMLScalarVolumeNode) ?
Completely overriding what was already in it but leaving untouched the node name and ID.

Thank You,
Alex

As long as the file is still compatible with the node type, you can try:

node = slicer.util.getNode("NODENAME")

storage = slicer.vtkMRMLNRRDStorageNode()
storage.SetFileName(filepath)
storage.ReadData(node)