The 5-year-old had been climbing in the tree in the grounds of Balaclava School in Dunedin at lunchtime, when she became wedged in a gap between two branches, about 1.5m off the ground.
Unable to pull her out, a teacher rang the Fire Service to come to the rescue, but when firefighters arrived, they could not pull her out either.
Firefighter Roger Hodgson said Olivia could not be freed when a crowbar or the jaws of life were used to try to force apart the branches.
She was finally extricated when cutting gear was used to separate the branches.
"She's been a very brave girl."
Olivia was stuck in the tree for about 15 minutes.
School principal Sally Direen said it was a relief Olivia had been freed without a scratch.
The small tree was popular with pupils, and there had been no previous incidents like this, she said.
The school's small trees and shrubs would not be out of bounds as a result.
"I never want to stop kids playing in trees and bushes. If I wanted to monitor every child trying to climb a tree, I would need 10 people on duty."