import xml.dom.minidom dom = xml.dom.minidom.parse('quarter.svg') def has_quarter(n) : if not isinstance(n, xml.dom.minidom.Element) : return False if 'quarternote' in n.getAttribute('id') : return True return False def get_quarter(n) : return list(filter(has_quarter, n.childNodes)) + sum([get_quarter(x) for x in n.childNodes],[]) ds = set([ filter(lambda y : y.tagName == 'path', filter(lambda y : isinstance(y, xml.dom.minidom.Element), x.childNodes))[0].getAttribute('d') for x in get_quarter(dom.documentElement)]) if len(ds) != 1 : raise ValueError('bad')