Get Warnings

from collections import defaultdict

all_warnings = defaultdict(list)

# Sort Warnings by Type
for w in doc.GetWarnings():
    description = w.GetDescriptionText()
    all_warnings[description].append(w)

for warning_type in all_warnings:
    warnings = all_warnings[war_typ]

    for w in warnings:
        element_ids = list(w.GetFailingElements()) + list(w.GetAdditionalElements())
        elements = [doc.GetElement(e_id) for e_id in element_ids]

⌨️ Happy Coding!
Erik Frits