As the Battle of Winterfell raged on Game of Thrones, a quieter battle was taking place inside the walls of the castle. Theon Greyjoy and a handful of soldiers stood in the godswood with Bran Stark, waiting for the Night King's inevitable arrival and hoping to be able to defend Bran. As they wait, it appears that they're also guarding the weirwood tree, the mystical tree imbued with ancient magic. So were the soldiers actually concerned with protecting the magical tree, or was it just coincidence that they were there?
Although the weirwood tree is very powerful, the soldiers are ultimately there to protect Bran. Theon personally swears to defend Bran, even if it means laying down his life, and he's the one in charge of the squad in the godswood. At the crux of the plan is using Bran as bait to lure the Night King to Winterfell, since Bran has been "marked" by the Night King and therefore can be found no matter where he goes. As Bran explains, he (as the Three-Eyed Raven) is the Night King's number one enemy because he holds all the knowledge and stories of the Seven Kingdoms; wiping him out would take all that history and memory away forever. It's not clear if his prophetic visions ever foresaw that the Night King would be killed in the godswood, but it's possible: Bran did give Arya the Valyrian steel dagger she used to kill the Night King.
The choice of location isn't entirely coincidental, though. In one of Bran's Three-Eyed Raven flashbacks, he watches the Night King's origin story: an ordinary man was captured by the Children of the Forest, bound to a weirwood tree, and stabbed through the heart with a piece of dragonglass. The Night King, as an entity, was thus born in front of a weirwood tree; it seems fitting that he dies in front of one, too.