Preheat your oven to 400 degrees Fahrenheit and line a large baking sheet with parchment paper. Ensure your puff pastry is thawed but still chilled to the touch, as this makes it much easier to handle and ensures the layers rise properly during the baking process.
Unroll one sheet of puff pastry onto the prepared baking sheet. Using a sharp knife or a pizza cutter, gently cut the pastry into a large triangle shape with a small rectangular trunk at the bottom. Remove the excess pastry scraps and set them aside to bake separately as snacks later.
Spread the basil pesto evenly over the triangle, leaving a tiny bit of space at the very edges. Sprinkle the shredded mozzarella and parmesan cheese over the pesto, along with the garlic powder. Place the second sheet of puff pastry directly on top of the first and cut it to match the triangle shape of the bottom layer.
Using your knife or pizza cutter, cut horizontal strips about one inch wide along both sides of the triangle, making sure to leave a center column intact for the tree trunk. The strips should start from the center and go out to the edges, creating the look of tree branches.
Take each pastry strip and gently twist it two or three times, depending on the length of the branch. Once all branches are twisted, brush the entire tree with the beaten egg wash to give it a golden sheen. Bake for 15 to 20 minutes, or until the pastry is puffed and deep golden brown. Sprinkle with fresh parsley and red pepper flakes before serving warm.