Place the sliced onions in a bowl and cover them with buttermilk. Let them soak for at least 20 minutes (up to 1 hour for extra tenderness).
Mix the flour, breadcrumbs, cornstarch, garlic powder, salt, and pepper in a separate bowl.
Remove the onions from the buttermilk, letting the excess drip off, and dredge them in the flour-breadcrumb mixture until well coated.
Heat about 1/2 inch of oil in a skillet over medium-high heat. Fry the onions until they become golden brown and crispy, about 2-3 minutes per batch.
Drain on paper towels and set aside to use as the topping later on.
Bring a large pot of salted water to a boil.
Blanch the green beans in salted boiling water for 3-4 minutes, then transfer to an ice bath. Drain and set aside.
In a large skillet, melt the butter over medium heat. Add the leeks and cook until softened, about 5 minutes. Add the mushrooms and garlic, sautéing until mushrooms are golden, about 5-6 minutes.
Stir the flour into the cooked leeks and mushrooms, and cook for 1 minute. Slowly whisk in the broth and heavy cream. Simmer for 5 minutes until thickened. Add nutmeg, thyme, salt, and pepper to taste.
Combine the green beans with the mushroom-leek sauce and mix well. Transfer to a casserole dish. Top with grated cheese.
Sprinkle the pretzel bun breadcrumbs evenly over the cheese layer and finish with crispy onions.
Place the casserole dish in the oven set at 375°F (190°C). Bake the casserole for 15-20 minutes until bubbly and golden.
Notes
Blanch Green Beans Properly - blanching the green beans in boiling water for just a few minutes helps them retain their vibrant color and crisp texture. Sauté thoroughly - cook the leeks and mushrooms until nicely softened and browned. Watch the baking time: Keep an eye on the casserole as it bakes. If the top is browning too quickly, cover it with foil to prevent burning while allowing the inside to heat through.