There is a city template (full name) and there is an array obtained after parsing XML, you need to check if the resulting array matches the existing template.
For example, the template city Dubna Moscow District
From XML, the city of Dubna belongs to the Moscow region.
Or, from the XML, the village of Petushki belongs to the “Petushki” from the template, that is, you need to discard the first occurrence of this VILLAGE and compare the existing Petushki with the Petushki from the template