def AreNodesSame(node_data_1, node_data_2):
  """Compares if two nodes are the same.

  Currently using a very basic algorithm: assume the nodes are the same if
  either their XPaths are the same or their dimension/positions are the same.

  Args:
    node_data_1: A dictionary of values about a DOM node.
    node_data_2: A dictionary of values about a DOM node.

  Returns:
    A boolean indicating whether the two nodes should be considered equivalent.
  """

  return (node_data_1['p'].lower() == node_data_2['p'].lower() or
          (node_data_1['w'] == node_data_2['w'] and
           node_data_1['h'] == node_data_2['h'] and
           node_data_1['x'] == node_data_2['x'] and
           node_data_1['y'] == node_data_2['y']))