01 - Preheat oven to 400°F. Line a large baking sheet with parchment paper.
02 - Combine sweet potatoes and apples in a large bowl.
03 - Whisk together maple syrup, melted butter, cinnamon, nutmeg, salt, and pepper in a separate small bowl until smooth.
04 - Pour glaze over sweet potatoes and apples. Toss thoroughly until evenly coated.
05 - Spread mixture in a single layer on prepared baking sheet, ensuring pieces are not overcrowded.
06 - Roast for 35-40 minutes, stirring halfway through cooking time, until sweet potatoes are tender and edges are caramelized.
07 - Sprinkle chopped pecans or walnuts over the top during the last 5 minutes of roasting, if using.
08 - Transfer to a serving dish, garnish with fresh thyme if desired, and serve warm.