1. Heat the oven to 400 degrees F. Grease a gratin dish (or shallow baking dish) with some of the butter.
2. Heat the potatoes if necessary and mash them with the butter, a sprinkle of salt and pepper, and a dash of nutmeg. Put the sweet potatoes in the gratin dish, and smooth the top.
3. Sprinkle the top with the chopped walnuts. Bake until the dish is hot and golden on top, 15 to 20 minutes.
4. Remove the dish from the oven. Sprinkle the top evenly with the brown sugar. Turn on the broiler and adjust the rack to about 4 inches from the heat source. Broil, watching carefully and turning the dish as necessary. When the sugar bubbles and browns, it's ready. Let it sit for a few minutes before serving.