Preheat oven to 350 degrees. Butter a 9-by-5-by-3-inch (2-quart) loaf pan; set aside. In a medium bowl, whisk together flour, baking powder, salt, and baking soda; set aside.
In the bowl of an electric mixer, cream butter and sugar until light and fluffy. Add eggs, one at a time, beating well after each addition. With mixer on low speed, add flour mixture in three additions, alternating with two additions of banana; mix until just combined. Stir in walnuts, if desired, by hand.
Pour batter into prepared pan. Bake until a toothpick inserted in center comes out with only a few moist crumbs attached, 60 to 70 minutes. Let cool 10 minutes in pan, then turn out of pan and let cool completely on a wire rack.
If your loaf looks brown on top before the inside is done cooking, tent it loosely with aluminum foil (so the top is protected yet steam can escape) for the remainder of the cooking time.