If the trail just weaves through the trees, then you will generally want to stand up. This gives you better balance retention and ability to weave between trees by having increased bike maneuverability and change of direction. Having precise judgment and being sure not to hit any trees is essential. For higher speed sections, the cone weave exercise is a great way to practice and fine tune all of the movements and techniques for doing this, plus to get comfortable with the wheels drifting should they break traction. To achieve this best, you just sway your body weight onto the appropriate footpeg to alter the bike’s direction with great ease. Weight the inside peg to lean it into the corner, then change your body weight distribution to the outside peg for increased traction around the corner and to stand the bike upright on the exit.
In a section of tight trees very close together, you can use a variation of this technique by actually slightly spreading your knees apart somewhat and using your arms to help very quickly sway the bike from one side to the other, allowing you to miss all of the approaching obstacles. When seated, you use so much more body energy trying to perform this very aggressive change of direction between the trees, plus you can’t do it as quickly and your legs tend to get in the way. The best option for most situations when there are just a few very tight trees then the trail opens up again is to stand when going through those tight trees for the benefits just mentioned then sit on the exit to maximize your acceleration and energy conservation.