Preheat your oven to 400°F (200°C). Brush the eggplant and potato slices with olive oil, season with salt and pepper, and roast on a baking sheet for about 20-25 minutes until tender and golden. Set aside.
In a large skillet, heat 2 tablespoons of olive oil over medium heat. Sauté the onions and garlic until soft. Add the lentils, crushed tomatoes, tomato paste, cinnamon, allspice, salt, and pepper. Bring to a boil, then reduce heat and simmer for 20-30 minutes until lentils are tender and the mixture thickens.
In a saucepan, melt the butter over medium heat. Stir in the flour and cook for 1-2 minutes until it forms a paste. Gradually whisk in the milk, continuing to whisk until the sauce thickens. Stir in the nutmeg and Parmesan cheese (if using). Remove from heat.
In a large baking dish, layer half of the potatoes, followed by half of the eggplants. Spread the lentil sauce over the vegetables, and then layer the remaining potatoes and eggplants on top. Pour the béchamel sauce over the top layer, spreading it evenly.
Reduce oven temperature to 350°F (175°C) and bake for 45 minutes to 1 hour, until the top is golden and bubbly. Allow to cool slightly before serving.