01 - Preheat the oven to 375°F. Grease a 9-inch pie dish or tart pan.
02 - Heat 1 tablespoon olive oil in a large skillet over medium heat. Sauté onion for 3 to 4 minutes until soft. Add garlic and cook for 30 seconds. Add spinach in batches, cooking until wilted (for fresh spinach), or if using frozen spinach, add thawed spinach after onion and garlic, cooking for 2 minutes.
03 - Transfer spinach mixture to a colander and press out excess moisture. Allow to cool slightly.
04 - In a large bowl, mix the cooled spinach mixture with feta, ricotta, eggs, dill, nutmeg, salt, and pepper until thoroughly combined.
05 - Roll out the pastry and fit it into the prepared pie dish, leaving some overhang.
06 - Spoon the filling evenly into the pastry shell and smooth the surface.
07 - Fold the excess pastry over the filling edges. Brush the pastry with the beaten egg and sprinkle with sesame seeds if desired.
08 - Bake for 35 to 40 minutes until the pastry is golden and the filling is set.
09 - Allow to cool for 10 minutes before slicing and serving.