merge_entities function

Combine and deduplicate entity datasets