Heat the oven to 350F. Grease a 9-inch square pan and line it with a parchment sling.
Make the streusel: rub the flour, brown sugar, cinnamon, salt and cold butter together with your fingertips until it looks like coarse crumbs with some pea-sized lumps. Stir in the nuts if using and refrigerate until needed.
Whisk the flour, baking powder, baking soda, salt, cinnamon and nutmeg together in a bowl and set aside.
Beat the softened butter and granulated sugar 3 to 4 minutes until pale and fluffy.
Add the eggs one at a time, beating after each, then beat in the vanilla.
Add the flour mixture in three additions, alternating with the sour cream in two. Mix on low and stop as soon as the last streak of flour disappears.
Fold in the diced apples by hand.
Spread the batter in the pan and level it. Scatter the chilled streusel evenly over the top.
Bake 45 to 55 minutes, until a skewer in the centre comes out with moist crumbs but no wet batter. Cover loosely with foil if the streusel browns early.
Cool in the pan at least 20 minutes before lifting out and cutting into 12 squares.