Instead of a hierarchy of expenses, have you considered a "tagging" approach? With tags, it would be easy to separate "groceries junkfood" from "groceries healthy". Then you could just search "groceries" to get your total bill. Also, you could tag some fast food with "diningout junkfood fastfood"; and if you search "junkfood", you'd get all the Big Macs and the candy bars lumped together.
In terms of categorization between optional and non-optional, that's a tough one. I mean, yes, the "groceries healthy" are non-optional, but do you really need to buy the expensive organic milk or would it be ok to substitute something less-expensive? And, as you already mentioned, you could probably cut back on some electrical usage if you had to.
I try to group my expenditures into broad buckets:
- home (includes home improvements, insurance, furniture, etc)
- clothing (also includes dry cleaning)
- food (includes groceries, dining out, etc)
- auto (includes gas, insurance, ...)
- utilities (includes gas & electric, cable, phone, cell phone, etc)
- entertainment (includes books, going out to the theater, renting movies, etc)
- computer (includes software, hardware, and supplies)
I also maintain a "cash" category which just tracks how much I pull from the ATM. I generally only use cash for miscellaneous purchases, so there isn't much point tracking these things independently -- unless there is a major spike in the amount of cash I pull in a given month or if there is a significant upward trend.
When I suspect that there is an area that I am over-spending, then I might decide to break it down further and monitor that one item for a few months. For example, I noticed that my food expenses were climbing; so I broke that down for a few months so I could see the difference between groceries and dining-out. It helped me understand why my food expenses were rising and decide what I wanted to do about it. Beyond this, though, I try not to obsess about the details of each and every category unless I see a disturbing trend.
Finally, you might already know about this, but I'll mention it just in case... assuming that you use credit/debit cards for most of your purchases, many software packages and online banking applications will help you do auto-categorization based on where you purchased something. The software reads your credit card statements from the bank's server, determines the company/address who put the charge through, and let's you say "All purchases from this place should go in the 'groceries' category". This is a huge time saver.