def optimizeTransforms(element, options):
 num = 0
 for transformAttr in ['transform', 'patternTransform', 'gradientTransform']:
  val = element.getAttribute(transformAttr)
  if (val != ''):
   transform = svg_transform_parser.parse(val)
   optimizeTransform(transform)
   newVal = serializeTransform(transform)
   if (len(newVal) < len(val)):
    if len(newVal):
     element.setAttribute(transformAttr, newVal)
    else:
     element.removeAttribute(transformAttr)
    num += (len(val) - len(newVal))
 for child in element.childNodes:
  if (child.nodeType == 1):
   num += optimizeTransforms(child, options)
 return num

def optimizeTransforms ( element , options ) : num = 0 for transformAttr in [ 'transform' , 'patternTransform' , 'gradientTransform' ] : val = element . getAttribute ( transformAttr ) if ( val != '' ) : transform = svg_transform_parser . parse ( val ) optimizeTransform ( transform ) newVal = serializeTransform ( transform ) if ( len ( newVal ) < len ( val ) ) : if len ( newVal ) : element . setAttribute ( transformAttr , newVal ) else : element . removeAttribute ( transformAttr ) num += ( len ( val ) - len ( newVal ) ) for child in element . childNodes : if ( child . nodeType == 1 ) : num += optimizeTransforms ( child , options ) return num
attempts to optimise transform specifications on the given node and its children .