def METHOD_NAME(certificate_arn, policy_name):
    paginator = iot.get_paginator("list_principal_things")
    list_things_iterator = paginator.paginate(
        principal=certificate_arn
    )
    for response in list_things_iterator:
        for thing_name in response["things"]:
            delete_thing(thing_name)
    iot.detach_policy(
        policyName=policy_name,
        target=certificate_arn
    )
    certificate_id = certificate_arn.split("/")[-1]
    iot.update_certificate(
        certificateId=certificate_id,
        newStatus="INACTIVE"
    )
    iot.delete_certificate(certificateId=certificate_id)