def check_for_conflicts(self):
        if not self.temp_custom_file or not self.database_xml:
            self.statusBar().showMessage("Please import both data files before checking for conflicts.")
            return

        custom_ids = {}

        # Парсинг кастомных данных
        custom_tree = ET.parse(self.temp_custom_file.name)

        # Сбор ID из кастомных данных
        for track in custom_tree.findall(".//track"):
            track_id_element = track.find("id")  # Ищем с маленькой буквы
            if track_id_element is not None and track_id_element.text is not None:
                custom_ids[f"<track> ID"] = track_id_element.text

        for handling in custom_tree.findall(".//track_car_handling"):
            handling_id_element = handling.find("ID")  # Ищем с заглавной буквы
            if handling_id_element is None:  # Если не нашли, ищем с маленькой буквы
                handling_id_element = handling.find("id")
            if handling_id_element is not None and handling_id_element.text is not None:
                custom_ids[f"<track_car_handling> ID"] = handling_id_element.text

        for distance in custom_tree.findall(".//track_fuel_distance"):
            distance_id_element = distance.find("ID")  # Ищем с заглавной буквы
            if distance_id_element is None:  # Если не нашли, ищем с маленькой буквы
                distance_id_element = distance.find("id")
            if distance_id_element is not None and distance_id_element.text is not None:
                custom_ids[f"<track_fuel_distance> ID"] = distance_id_element.text

        for model in custom_tree.findall(".//track_model"):
            model_id_element = model.find("id")  # Ищем с маленькой буквы
            if model_id_element is None:  # Если не нашли, ищем с заглавной буквы
                model_id_element = model.find("ID")
            if model_id_element is not None and model_id_element.text is not None:
                custom_ids[f"<track_model> ID"] = model_id_element.text
                
            # Поиск дополнительных тегов в track_model
            for child in model:
                if child.tag in ["calender_glyph", "calendar_glyph", "track_id", "leaderboard_id"]:
                    if child.text is not None:
                        custom_ids[f"<track_model> {child.tag}"] = child.text

        for difficulties in custom_tree.findall(".//track_difficulties"):
            difficulties_id_element = difficulties.find("ID")  # Ищем с заглавной буквы
            if difficulties_id_element is None:  # Если не нашли, ищем с маленькой буквы
                difficulties_id_element = difficulties.find("id")
            if difficulties_id_element is not None and difficulties_id_element.text is not None:
                custom_ids[f"<track_difficulties> ID"] = difficulties_id_element.text
                
            # Ищем трек ID с небольшими и большими буквами
            track_id_element = difficulties.find("track")  # Обычно с маленькой
            if track_id_element is None:  # Если не нашли, ищем с заглавной буквы
                track_id_element = difficulties.find("Track")
            if track_id_element is not None and track_id_element.text is not None:
                custom_ids[f"<track_difficulties> track"] = track_id_element.text

        print(f"Custom IDs: {custom_ids}")  # Выводим найденные идентификаторы кастомного трека

        # Проверка конфликтов с базой данных
        conflicts = {}
        database_tree = ET.parse(self.database_xml)

        print("Checking for conflicts in the database...")

        # Определяем пространство имен
        ns = {'ns': 'schemaF12013.xml', 'ns2': 'schemaF12014.xml'}

        # Просматриваем все элементы базы данных
        for database_element in database_tree.findall(".//ns:track", ns) + \
                                database_tree.findall(".//ns2:track", ns) + \
                                database_tree.findall(".//ns:track_car_handling", ns) + \
                                database_tree.findall(".//ns2:track_car_handling", ns) + \
                                database_tree.findall(".//ns:track_fuel_distance", ns) + \
                                database_tree.findall(".//ns2:track_fuel_distance", ns) + \
                                database_tree.findall(".//ns:track_model", ns) + \
                                database_tree.findall(".//ns2:track_model", ns) + \
                                database_tree.findall(".//ns:track_difficulties", ns) + \
                                database_tree.findall(".//ns2:track_difficulties", ns):

            db_id = database_element.find("ns:id", ns)  # Ищем с маленькой буквы
            if db_id is None:  # Если не нашли, ищем с заглавной буквы
                db_id = database_element.find("ns:ID", ns)

            if db_id is None:  # Если не нашли, проверяем для 2014
                db_id = database_element.find("ns2:id", ns)
                if db_id is None:
                    db_id = database_element.find("ns2:ID", ns)

            if db_id is not None and db_id.text is not None:
                print(f"Found in database: {database_element.tag} -> {db_id.text}")

                # Смотрим, есть ли совпадение с кастомными ID
                for id_tag, custom_id in custom_ids.items():
                    if db_id.text == custom_id:
                        conflicts[id_tag] = custom_id
                        print(f"Conflict detected: {id_tag} -> {custom_id}")

        if conflicts:
            print("Conflicts found: ", conflicts)
            conflict_dialog = IDConflictDialog(conflicts, self.update_temp_custom_file, self)
            conflict_dialog.exec_()
        else:
            QMessageBox.information(self, "No Conflicts", "No ID conflicts found.")



проблема в том, что он не ищет во внутренних тегах корректно, вот логи:


Custom IDs: {'<track> ID': '115', '<track_car_handling> ID': '32', '<track_fuel_distance> ID': '31', '<track_model> ID': '22', '<track_model> calender_glyph': '7', '<track_model> calendar_glyph': '9', '<track_model> leaderboard_id': '17', '<track_model> track_id': '220', '<track_difficulties> ID': '26', '<track_difficulties> track': '114'}
Checking for conflicts in the database...
Found in database: {schemaF12014.xml}track -> 79
Found in database: {schemaF12014.xml}track -> 82
Found in database: {schemaF12014.xml}track -> 83
Found in database: {schemaF12014.xml}track -> 84
Found in database: {schemaF12014.xml}track -> 85
Found in database: {schemaF12014.xml}track -> 86
Found in database: {schemaF12014.xml}track -> 87
Found in database: {schemaF12014.xml}track -> 88
Found in database: {schemaF12014.xml}track -> 89
Found in database: {schemaF12014.xml}track -> 91
Found in database: {schemaF12014.xml}track -> 92
Found in database: {schemaF12014.xml}track -> 93
Found in database: {schemaF12014.xml}track -> 95
Found in database: {schemaF12014.xml}track -> 96
Found in database: {schemaF12014.xml}track -> 97
Found in database: {schemaF12014.xml}track -> 98
Found in database: {schemaF12014.xml}track -> 99
Found in database: {schemaF12014.xml}track -> 101
Found in database: {schemaF12014.xml}track -> 104
Found in database: {schemaF12014.xml}track -> 111
Found in database: {schemaF12014.xml}track -> 112
Found in database: {schemaF12014.xml}track_car_handling -> 1
Found in database: {schemaF12014.xml}track_car_handling -> 2
Found in database: {schemaF12014.xml}track_car_handling -> 3
Found in database: {schemaF12014.xml}track_car_handling -> 4
Found in database: {schemaF12014.xml}track_car_handling -> 5
Found in database: {schemaF12014.xml}track_car_handling -> 6
Found in database: {schemaF12014.xml}track_car_handling -> 8
Found in database: {schemaF12014.xml}track_car_handling -> 9
Conflict detected: <track_model> calendar_glyph -> 9
Found in database: {schemaF12014.xml}track_car_handling -> 10
Found in database: {schemaF12014.xml}track_car_handling -> 11
Found in database: {schemaF12014.xml}track_car_handling -> 12
Found in database: {schemaF12014.xml}track_car_handling -> 13
Found in database: {schemaF12014.xml}track_car_handling -> 14
Found in database: {schemaF12014.xml}track_car_handling -> 15
Found in database: {schemaF12014.xml}track_car_handling -> 16
Found in database: {schemaF12014.xml}track_car_handling -> 18
Found in database: {schemaF12014.xml}track_car_handling -> 19
Found in database: {schemaF12014.xml}track_car_handling -> 21
Found in database: {schemaF12014.xml}track_car_handling -> 23
Found in database: {schemaF12014.xml}track_car_handling -> 29
Found in database: {schemaF12014.xml}track_fuel_distance -> 20
Found in database: {schemaF12014.xml}track_fuel_distance -> 21
Found in database: {schemaF12014.xml}track_fuel_distance -> 22
Conflict detected: <track_model> ID -> 22
Found in database: {schemaF12014.xml}track_fuel_distance -> 24
Found in database: {schemaF12014.xml}track_fuel_distance -> 25
Found in database: {schemaF12014.xml}track_fuel_distance -> 1
Found in database: {schemaF12014.xml}track_fuel_distance -> 2
Found in database: {schemaF12014.xml}track_fuel_distance -> 3
Found in database: {schemaF12014.xml}track_fuel_distance -> 4
Found in database: {schemaF12014.xml}track_fuel_distance -> 5
Found in database: {schemaF12014.xml}track_fuel_distance -> 6
Found in database: {schemaF12014.xml}track_fuel_distance -> 7
Conflict detected: <track_model> calender_glyph -> 7
Found in database: {schemaF12014.xml}track_fuel_distance -> 8
Found in database: {schemaF12014.xml}track_fuel_distance -> 9
Conflict detected: <track_model> calendar_glyph -> 9
Found in database: {schemaF12014.xml}track_fuel_distance -> 10
Found in database: {schemaF12014.xml}track_fuel_distance -> 11
Found in database: {schemaF12014.xml}track_fuel_distance -> 12
Found in database: {schemaF12014.xml}track_fuel_distance -> 13
Found in database: {schemaF12014.xml}track_fuel_distance -> 14
Found in database: {schemaF12014.xml}track_fuel_distance -> 15
Found in database: {schemaF12014.xml}track_fuel_distance -> 16
Found in database: {schemaF12014.xml}track_fuel_distance -> 17
Conflict detected: <track_model> leaderboard_id -> 17
Found in database: {schemaF12014.xml}track_fuel_distance -> 18
Found in database: {schemaF12014.xml}track_fuel_distance -> 19
Found in database: {schemaF12014.xml}track_fuel_distance -> 23
Found in database: {schemaF12014.xml}track_fuel_distance -> 26
Conflict detected: <track_difficulties> ID -> 26
Found in database: {schemaF12014.xml}track_fuel_distance -> 27
Found in database: {schemaF12014.xml}track_fuel_distance -> 28
Found in database: {schemaF12014.xml}track_model -> 44
Found in database: {schemaF12014.xml}track_model -> 118
Found in database: {schemaF12014.xml}track_model -> 119
Found in database: {schemaF12014.xml}track_model -> 176
Found in database: {schemaF12014.xml}track_model -> 179
Found in database: {schemaF12014.xml}track_model -> 180
Found in database: {schemaF12014.xml}track_model -> 181
Found in database: {schemaF12014.xml}track_model -> 184
Found in database: {schemaF12014.xml}track_model -> 185
Found in database: {schemaF12014.xml}track_model -> 186
Found in database: {schemaF12014.xml}track_model -> 189
Found in database: {schemaF12014.xml}track_model -> 190
Found in database: {schemaF12014.xml}track_model -> 191
Found in database: {schemaF12014.xml}track_model -> 193
Found in database: {schemaF12014.xml}track_model -> 194
Found in database: {schemaF12014.xml}track_model -> 195
Found in database: {schemaF12014.xml}track_model -> 196
Found in database: {schemaF12014.xml}track_model -> 199
Found in database: {schemaF12014.xml}track_model -> 201
Found in database: {schemaF12014.xml}track_model -> 205
Found in database: {schemaF12014.xml}track_model -> 212
Found in database: {schemaF12014.xml}track_model -> 213
Found in database: {schemaF12014.xml}track_model -> 220
Conflict detected: <track_model> track_id -> 220
Found in database: {schemaF12014.xml}track_model -> 221
Conflicts found:  {'<track_model> calendar_glyph': '9', '<track_model> ID': '22', '<track_model> calender_glyph': '7', '<track_model> leaderboard_id': '17', '<track_difficulties> ID': '26', '<track_model> track_id': '220'}


вот тут: Custom IDs: {'<track> ID': '115', '<track_car_handling> ID': '32', '<track_fuel_distance> ID': '31', '<track_model> ID': '22', '<track_model> calender_glyph': '7', '<track_model> calendar_glyph': '9', '<track_model> leaderboard_id': '17', '<track_model> track_id': '220', '<track_difficulties> ID': '26', '<track_difficulties> track': '114'}


а он находит айди совпадающий в другом теге, а нужно здесь например в track_model, а он их нашел по первому попавшему номеру совпадающему:
Found in database: {schemaF12014.xml}track_fuel_distance -> 15
Found in database: {schemaF12014.xml}track_fuel_distance -> 16
Found in database: {schemaF12014.xml}track_fuel_distance -> 17
Conflict detected: <track_model> leaderboard_id -> 17
Found in database: {schemaF12014.xml}track_fuel_distance -> 18
Found in database: {schemaF12014.xml}track_fuel_distance -> 19

А как надо:

Found in database: {schemaF12014.xml}track_model -> 212
Found in database: {schemaF12014.xml}track_model -> 213
Found in database: {schemaF12014.xml}track_model -> 220
Conflict detected: <track_model> track_id -> 220
Found in database: {schemaF12014.xml}track_model -> 221


чтобы материнский тег и дочерний было соотношение верное, они указаны в списке кастом_айди


это прога на питоне 5 заголвоок:

import sys
import tempfile
import os
import xml.etree.ElementTree as ET
from PyQt5.QtWidgets import (QApplication, QMainWindow, QAction, QMessageBox, 
                             QVBoxLayout, QWidget, QPushButton, QLabel, QFileDialog, 
                             QDialog, QLineEdit)
from functools import partial