def getattr_qualname(obj, qualname):
    """
    Looks up a qualified name in (nested) attributes of `obj`.

    Splits `name` at dots, and successively looks up attributes in `obj`.
    """
    if qualname == "":
        return obj
    result = obj
    for part in qualname.split("."):
        result = getattr(result, part)
    return result