Preheat the oven to gas 6, 200°C, fan 180°C. Roll out the pastry and use to line a 23cm (9in) flan tin. Line with nonstick baking paper and fill with baking beans. Chill for 30 minutes.
Bake the pastry in the centre of the oven for 15 minutes. Remove paper and beans and bake for another 5 minutes until the pastry is light golden. Reduce the oven temperature to gas 4, 180°C, fan 160°C.
Make the filling. Trim the leeks and peel off any tough outer leaves, cut the top portion in half lengthways and rinse out any dirt. Shake dry, then slice finely. Heat the butter in a large frying pan with 1 tbsp water. Add the leeks, cover and cook for 5 minutes until softened, remove the lid and cook off all the moisture.
Beat together the thyme, cheese, cream, egg and yolk. Add leeks and season. Pour into the flan case and return to the oven on gas 4, 180°C, fan 160°C. Bake for 35 minutes or until the filling is just set.