Try this procedure, I have successfully used this for an X-Trail key before
Insert the key into the ignition, but don't start the car, then remove the key. Do this about six times, although it can take up to 10 times. When your car accepts the Key, the hazard lights will flash twice. Now you're in program mode.