Preheat your oven to 350°F (175°C). Grease and flour a 9-inch square baking pan or a 9-inch springform pan. If using a springform, line the bottom with parchment paper for easier removal.
In a medium bowl, whisk together the flour, brown sugar, cinnamon, and salt for the streusel. Using your fingertips or a pastry cutter, work the cold butter into the dry ingredients until the mixture resembles coarse crumbs with pea-sized pieces of butter visible. Mix in the chopped nuts if using. Refrigerate while preparing the cake batter.
In a medium bowl, whisk together the flour, baking powder, baking soda, salt, cinnamon, and nutmeg for the cake.
In a large bowl using an electric mixer, cream together the softened butter and granulated sugar until light and fluffy, about 3-4 minutes.
Add the eggs one at a time, beating well after each addition. Mix in the vanilla extract.
Gradually add the dry ingredients to the butter mixture in three parts, alternating with the sour cream (begin and end with dry ingredients). Mix just until incorporated after each addition.
Gently fold in the diced apples until evenly distributed throughout the batter.
Spread the batter evenly in the prepared pan. Remove the streusel from the refrigerator and sprinkle it generously over the top, gently pressing it into the batter slightly.
Bake for 45-50 minutes, or until a toothpick inserted into the center comes out clean or with a few moist crumbs. If the streusel begins to brown too quickly, loosely cover with aluminum foil for the remainder of the baking time.
Allow the cake to cool in the pan for at least 15 minutes before serving.