The branch works because it comes from a special tree that can hold spiritual energy, and during the moment of strong moonlight, that energy is “activated” or amplified. So the wood temporarily becomes a kind of spirit-conducting material.
So we see 3 things that helped killing the ghost:
-the moonlight peak makes the barrier between worlds weaker
-the tree wood becomes a spiritual medium
-and the ghost is in a vulnerable, manifested state

Can someone please explain how exactly Dohwi get the power to eliminate the first ghost near the peach blossom tree as he was nearly being killed. He seemed to pick up a branch/stick and what? I couldn't understand, if he did posses the power to absorb ghost's powers, why didn't he do earlier?