In the sixth season of Arrow, Oliver Queen was in prison. Laurel Lance found a way of getting him out by way of a loophole, what was the loophole that enabled Oliver to walk free?
The answer was in the words of Laurel Lance (Earth-2) only:
"I made a deal with the feds. A trade. Diaz for your husband. If Oliver agrees to assist him with his case against Diaz, he'll be a free man again."
If you want to know from a real-life perspective then yes it's possible, refer to whitecollarcrimeresources.com:
you should know the cooperation is not necessarily to get out of jail free card. In some parts of the country if you cooperate and you help them catch someone else and that someone else goes to prison, you can get a significant sentencing reduction. Sometimes you can get a sentencing reduction significant enough that you don’t actually go to prison yourself.