Inside the ‘painstaking’ negotiations that led to the biggest prisoner swap since the Cold War