AAM failure is a possible cause for loss of key recognition (or the slot that serves that key). If it will not reprogram per instructions in your owner's manual, your key is bad (or AAM slot) and will have to be replaced. You can have only 8 keys for your car ever, so good luck.
__________________ Be careful about reading health books. You may die of a misprint.- Mark Twain
Only time I have had my battery disconnected was when I had the battery replaced. The road side assistant dude came to my house and replaced it in my garage, did his programming thing and all was good.
Next time something like this happens I would call road side first before having to pay a large towing bill and diag from the shop. Just for being a MB owner you can call the 800 number (usually posted on the drivers side visor) and for the life of the vehicle they will (at no cost to you)
Change a flat tire
Put enough gas in the tank to get you to a gas station if you run out of gas
Jump start your vehicle if you can't start it. My case was that is wouldn't start so they brought out the new battery for me. Cost me $100 (no shop fees)
They also came to my home and replaced the window switch unit when the drivers side switch went bad. Cost me $125 for the part (no shop fees)
I know this doesn't really answer your question but I thought I would throw out the suggestion. The road side 800# has been really good to me so far.
Good luck with the key, hope it's simple and not too expensive for you.