had same problem on one of my 4x4 ,blown BRAKE FUSE , while you at it make sure your clearance at the foot peddle brake switch hasnt been interfeared with and that the switch is working, and that your brake globes are ok
My drive is a 2010 550 TI Pathfinder & I had the same symptom as you.
I would suspect that Nissan are using basically the same circuitry across their auto fleet.
The Pathfinder circuit starts at a fuse supplying power to a brake pedal operated switch. There are two brake pedal switches, one for brake lights, one for shift control & I think as well, cruise control disengage.
With your foot on the brake, power is then supplied to a "Park position switch" which is located in the shift selector assy. i.e. you must be in "Park".
This circuit design stops the shift release solenoid operating every time the brakes pedal is depressed once you are out of "Park".
Power then is supplied to the shift release solenoid.
Solenoid & park position switch are both in the shift assy.
Fuse, ok ?, power to brake switch ok ?, power out of braked switch ok ?
After that you need to access the transmission selector assy, there will be a electrical disconnect connector.
With connector removed, power should be seen on the removed plug when in "Park" & foot on brake (ignition on of course!)
I cannot advise on D40 shift mechanism access.
Nissan did not have replacement parts for the shift mechanism, neither solenoid or park switch.
They could sell me a new assy for $800!!!!!
I found a genuine Nissan solenoid in Japan, $120 delivered & the micro switch (identical part number) locally for about $10.
My problem was the park position switch, I also had to replace the solenoid as I damaged it trying to test it for operation by hot wiring it but did not realise their is a diode across the positive & negative connections & inadvertently powered it incorrectly & blew the diode!