def safe_iterator(node, tag=None):
 if (node is None):
  return []
 if hasattr(node, 'iter'):
  return node.iter(tag)
 else:
  return node.getiterator(tag)

def safe_iterator ( node , tag = None ) : if ( node is None ) : return [ ] if hasattr ( node , 'iter' ) : return node . iter ( tag ) else : return node . getiterator ( tag )
return an iterator that is compatible with python 2 .