def METHOD_NAME(circuit, defn):
    name = circuit.name
    if not hasattr(circuit, "instances"):
        return defn
    for i in circuit.instances:
        METHOD_NAME(type(i), defn)
    if name not in defn:
        defn[name] = circuit
    return defn