How do you kill the spirit in the tree in The Witcher 3?

Quick answer: Attack the heart of the tree inside the cave. Kill each wave of endrega workers, then hit the heart while the roots move away, until it is destroyed.
Show walkthrough (quest spoilers)
Start the fight
Tell the spirit you will not help it, or attack it after gathering the ritual items. You can also trick it at the end of the ritual, which kills it without a fight. Either way the result is the same: the spirit dies.
Endrega waves
During the fight the spirit summons waves of endrega workers. While they are alive, roots cover the heart and block your attacks. Fight in the open, dodge their bites and use Igni or Yrden to thin them out.
Hit the heart
When a wave is dead, the roots move and the heart is open. Rush in and hit it as much as you can before the next wave. Repeat until the heart breaks.
After the fight
With the spirit dead, Downwarren is safe but the orphans of Crookback Bog are lost. Go back to the man from Downwarren to finish Ladies of the Wood. See the Whispering Hillock walkthrough for what comes next.
