The complicated prisoner swap deal took more than six months of at-times delicate discussions to arrange.