BUG: Fixed crash in vtkMRMLTransformNode::GetMatrixTransformToNode
How to reproduce the crash:
# Create transform hierarchy t1-t2-t3
t1=slicer.vtkMRMLTransformNode()
t2=slicer.vtkMRMLTransformNode()
t3=slicer.vtkMRMLTransformNode()
slicer.mrmlScene.AddNode(t1)
slicer.mrmlScene.AddNode(t2)
slicer.mrmlScene.AddNode(t3)
t2.SetAndObserveTransformNodeID(t1.GetID())
t3.SetAndObserveTransformNodeID(t2.GetID())
# Get t3 to t1 transform
m = vtk.vtkMatrix4x4()
t3.GetMatrixTransformToNode(t1, m)
The problem was caused by infinite recursion. There were no tests for GetMatrixTransformToNode and GetTransformToNode methods and they did not work well. Also, the transform node heavily used recursion in several methods when only a simple iteration on the transform tree was needed, which made computation time magnitudes higher (although it was still very quick, so it was not noticeable) and made the code harder to read and debug.
Solution: Replaced all the unnecessary recursive method calls by simple for loops. Added tests for Get(Matrix)TransformToNode methods.