Heat the oil in a frying pan, then fry the onion until golden. Add the carrots and all but a sprinkling of thyme.
Pour in the wine, 150ml water and the tomatoes, then sprinkle in the stock cubes and simmer for 10 mins. Tip in the can of lentils, including their juice, then cover and simmer for another 10 mins until the carrots still have a bit of bite and the lentils are pulpy.
Meanwhile, boil the sweet potatoes for 15 mins until tender, drain well, then mash with the butter and season to taste.
Pile the lentil mixture into a pie dish, spoon the mash on top, then sprinkle over the cheese and remaining thyme. The pie can now be covered and chilled for 2 days, or frozen for up to a month.
Heat oven to 190C/170C fan/gas 5. Cook for 20 mins if cooking straight away, or for 40 mins from chilled, until golden and hot all the way through. Serve with broccoli.