code: def itemTransform(item, root):
      ## Return the transformation mapping item to root
      ## (actually to parent coordinate system of root)
  
      if item is root:
          tr = QtGui.QTransform()
          tr.translate(*item.pos())
          tr = tr * item.transform()
          return tr
  
      if (
          item.flags()
          & item.GraphicsItemFlag.ItemIgnoresTransformations
      ):
          pos = item.pos()
          parent = item.parentItem()
          if parent is not None:
              pos = itemTransform(parent, root).map(pos)
          tr = QtGui.QTransform()
          tr.translate(pos.x(), pos.y())
          tr = item.transform() * tr
      else:
          ## find next parent that is either the root item or
          ## an item that ignores its transformation
          nextRoot = item
          while True:
              nextRoot = nextRoot.parentItem()
              if nextRoot is None:
                  nextRoot = root
                  break
              if nextRoot is root or (
                  nextRoot.flags()
                  & nextRoot.GraphicsItemFlag.ItemIgnoresTransformations
              ):
                  break
  
          if isinstance(nextRoot, QtWidgets.QGraphicsScene):
              tr = item.sceneTransform()
          else:
              tr = (
                  itemTransform(nextRoot, root)
                  * item.itemTransform(nextRoot)[0]
              )
  
      return tr
  
imports: import contextlib
  import re
  import xml.dom.minidom
  import numpy
  from ..None import PlotCurveItem, ScatterPlotItem, debug
  from ..None import functions
  from ..parametertree import Parameter
  from ..Qt import QtCore, QtGui, QtSvg, QtWidgets
  from .Exporter import Exporter
label_desc: Use image node_id 4 for calling a global function with example usage: itemTransform(item, root) and returns: tr, tr