def mayContainTextNodes(node):
 try:
  return node.mayContainTextNodes
 except AttributeError:
  pass
 result = True
 if (node.nodeType != 1):
  result = False
 elif (node.namespaceURI != NS['SVG']):
  result = True
 elif (node.nodeName in ['rect', 'circle', 'ellipse', 'line', 'polygon', 'polyline', 'path', 'image', 'stop']):
  result = False
 elif (node.nodeName in ['g', 'clipPath', 'marker', 'mask', 'pattern', 'linearGradient', 'radialGradient', 'symbol']):
  result = False
  for child in node.childNodes:
   if mayContainTextNodes(child):
    result = True
 node.mayContainTextNodes = result
 return result

def mayContainTextNodes ( node ) : try : return node . mayContainTextNodes except AttributeError : pass result = True if ( node . nodeType != 1 ) : result = False elif ( node . namespaceURI != NS [ 'SVG' ] ) : result = True elif ( node . nodeName in [ 'rect' , 'circle' , 'ellipse' , 'line' , 'polygon' , 'polyline' , 'path' , 'image' , 'stop' ] ) : result = False elif ( node . nodeName in [ 'g' , 'clipPath' , 'marker' , 'mask' , 'pattern' , 'linearGradient' , 'radialGradient' , 'symbol' ] ) : result = False for child in node . childNodes : if mayContainTextNodes ( child ) : result = True node . mayContainTextNodes = result return result
returns true if the passed-in node is probably a text element .