The quicker and easier way would be to file and win a law suit against Apple and AT&T that would require them to provide the unlock codes upon termination of the contract. You know how long it takes stuff to get through courts.
At one point in time there was a legal decision that required carriers to provide unlock codes when the client's contract expired. I has an iPAQ (HP) through T-Mobile some 10 years ago. When I terminated my service with T-Mobile, I called and requested the unlock code. They gave it to me, because they had to. Six months before, they would not give me the unlock codes. I don't know why the iPhone is different or if there was a change in the law. But it would seem to me that a case could be made to require Apple or AT&T to provide the unlock codes once the contract expired. But then, that may be why I'm not a lawyer.