Transformation graph for quick calculation of concatenated transforms

Thanks a lot! This looks exactly like what I need. However, I have problems with executing the command. Given the example above, I tried the following:
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(nT2SToT2.SafeDownCast(vtk.vtkGeneralTransform()), nHRToT1.SafeDownCast(vtk.vtkGeneralTransform()), T.SafeDownCast(vtk.vtkGeneralTransform()))

(note: I had to SafeDownCast() - all transforms are linear - to a vtkGeneralTransform. I could have tried the matrix4x4 version you mentioned, but I wanted to try the general approach for more complex scenarios later).
The command runs, but the result is wrong as I receive the identity matrix.
I also received the following warning in the log:
Generic Warning: In /Users/kitware/Dashboards/Package/Slicer-462/Libs/MRML/Core/vtkMRMLTransformNode.cxx, line 472 vtkMRMLTransformNode::GetTransformToNode failed: transformSourceToTarget is invalid

Could you give a hint regarding the syntax?
Thanks!