Photograph: Jonathan Kennedy
For the topping, melt the butter in a pan. Add the flour; stir over a medium heat for 1 minute. Off the heat, whisk in the milk bit by bit. Return to the heat and simmer, stirring, until thick. Take off the heat; stir in half the feta. Season. Preheat the oven to 180°C, fan 160°C, gas 4.
Melt the butter in a frying pan; cook the leeks on a medium heat, uncovered, until soft.
Mix the lemon zest and juice into the leeks. Scatter a third of the cooked leeks into a buttered 40 x 20cm ovenproof dish. Mix the cream with the thyme; season generously.
Layer half the sweet potato on the leeks, then repeat: leeks, potato, leeks. Pour on the cream.
Stir the eggs into the topping and spoon over the vegetables. Sprinkle with the remaining feta. Bake for 1 hour 15 minutes.
Get ahead: assemble a day ahead; refrigerate. Allow an extra 20 minutes if baking from chilled. Or assemble in an ovenproof dish; cover with clingfilm and freeze. Defrost fully before cooking and allow the extra 20 minutes if still a bit cold.