1. Heat a large frying pan, melt the butter, then add the onion and leeks. Cover, then very gently cook for 15 mins until soft. Add the potatoes after 5 mins cooking.
2. Stir in the flour, turn up the heat, then add the stock, stirring until the mix thickens a little. Take off the heat, then stir in the crème fraîche, mustard and ham. Season to taste, then cool, if you have time. Spoon the mix into a large pie dish, adding a couple of bay leaves. Heat oven to 220C/fan 200C/gas 7.
3. Roll out the pastry on a floured surface to the thickness of a £1 coin. Cut a pastry strip the same width as the lip of the dish, wet the edge of the dish with egg, then fix the strip around it. Brush the top with egg, then lay over the remaining pastry.
4. Trim pastry to the edge of the dish, then ruffle the cut edges with the knife blade to help the layers rise. Cut a few slits to let the steam escape, decorate with bay leaves, if you like, then brush all over the top with egg. Can be done up to a day ahead, keep chilled. Bake for 30 mins until risen.