Mix the flour and the cubed butter by hand. The mixture will be quite crumbly.
Add 1 whole egg, powdered sugar, salt, vanilla extract, baking powder, sour cream, and lemon zest. Knead thoroughly. Add more flour if necessary.
Divide the dough into 2 balls, cover and let rest for 20 minutes.
Peel the apples, core, and shred them. Add the sugar, the cinnamon, and the lemon juice. Mix well and drain the juice. Drink the apple juice, it is delicious. :)
Heat the oven to 180°C (355°F). Butter and flour your baking tin.
On a floured surface roll out one part of the dough to the size of the baking tin (11x8), then lay it in.
Sprinkle with half of the ground walnuts (optional). Spread the apples on the dough; sprinkle it with the remaining walnuts. Roll out the top crust and place over the apples, sealing the edges and making slits in it.
Prick to allow vapor to escape, and brush with egg wash.
Bake the cake for 30 minutes, until the top is light-browned. Let it cool. Cut into squares, sprinkle with powdered sugar, and serve.