def compare_tree_to_dict(actual, expected, keys):
 for (elem, data) in zip(actual, expected):
  for key in keys:
   if (elem.get(key) != data.get(key)):
    return False
 return True

def compare_tree_to_dict ( actual , expected , keys ) : for ( elem , data ) in zip ( actual , expected ) : for key in keys : if ( elem . get ( key ) != data . get ( key ) ) : return False return True
compare parts of lxml .