Photograph: Jan Baldwin
Roughly chop the onion, leek, celery and carrot. Put the chicken in a wide pan with the vegetables, a level teaspoon of salt and the bay leaf and thyme. Add enough stock just to cover the contents and bring gently to the boil. Skim off any scum, reduce the heat, cover with a lid and poach the chicken for about 30 minutes or until the flesh feels tender when pierced with a knife and the juices run clear. Leave to cool in the stock.
When the chicken is cool enough to handle, strain off but reserve the stock (keep this for making the sauce) and discard the vegetables. Remove the skin from the chicken and discard. Pull all the meat from the bones and transfer to a 1.2 litre pie dish.
Bring 600ml of the reserved stock to the boil, add the carrots and simmer for 5 minutes. Add the leeks and, as soon as they come back to the boil, remove all the veg with a slotted spoon and add to the chicken.
Melt the butter in another pan, stir in the flour and cook for a few minutes, stirring constantly, to make a roux. Add a small ladleful of the hot stock, stirring well with a wooden spoon or balloon whisk. Repeat, stirring all the time, until all the stock has been added. Season and stir in the cream, if using. Pour the sauce over the chicken and veg and give it a stir. Leave to cool. Preheat the oven to 220°C, fan 200°C, gas 7.
On a floured surface, roll out the pastry to about ½cm thick, enough to generously cover the pie dish with an overlap. Butter the edge of the dish, cut a strip of pastry 2½cm wide from around the outside of the rolled-out pastry and press firmly round the edge of the dish. Brush with cold water and place the rest of the pastry on top, firming down the edge. Trim away any excess with a sharp knife. Crimp the edge with a fork and decorate the top with leaves or another design made from the pastry trimmings. Use a dab of water to make the bits stick.
Brush the pie with the beaten egg. Bake for 45-50 minutes until golden and bubbling hot.
Get ahead: the pastry can be made a couple of days in advance and freezes well. Assemble the pie a day ahead, glaze and chill (unbaked), and bring back to room temperature before cooking. You can brush the pastry with beaten egg once more before baking, if you want to make the pastry really shiny.