1. Use a little butter to grease the grain dish. Melt the remaining butter with the oil in a frying pan over a low heat. Add the onion and garlic and soften for about 10 minutes. Add the ham, if using and keep warm on top of the stove.
2. Preheat the oven to 190 C/375 F/Gas 5. In a separate basin, beat the eggs then add the milk. Stir in three-quarters of the cheese and season. Grate about a quarter of the nutmeg into the mixture.
3. Grate the potatoes using a grater or a food processor if you have one. Squeeze them between your hands to extract as much water as possible. Add them to the egg mixture along with the ham, if using and onion and the parsley and mix well.
4. Pour into the prepared dish, scatter the remaining cheese on top, place on a baking sheet and bake at the top of the preheated oven for about 30 minutes until golden brown.