He was right. He should've been recognized as a key player. But the idea that being seen as a key player in the company requires you to be higher in the hierarchy is a fallacy.
The art of good company structure is keeping the hierarchy relatively flat (not non-existent, but still relatively flat), so hierarchy does not become the de-facto tool for "recognition" of an employee. There was no reason this programmer shouldn't have gotten more respect (during decision making) and more money even than his direct boss, but staying in the position he's in, where he's contributing his best.
Apple's infamous "top 100" meetings pick 100 of the most influential people in the company for a secret retreat. They're not selected by hierarchy. They're selected by their individual contributions. There's a lot of wisdom in that way of doing things.
And a side note about mental conditions. It's easy to say "oh he was probably unstable anyway", but that's bullshit. Every one of you "stable" people have a breaking point. Every one of you. Environmental stress is a huge factor affecting our mental health. So if this happens at your company, don't look for external excuses. Look around yourself, identify the causes, fix them.