(Not a teacher)
I would say things which are part of the tree are 'on' it:
The leaves on the tree.
The branches on the tree.
Things which are not part of the tree are 'in' it:
The boy is in the tree.
The cat was stuck in the tree.
There's a carrier bag caught in the tree.
Monkey's spend most of their life living in the trees.
If you wanted to specify something was actually in the interior of the tree, then use 'inside':
Many insects lay their eggs inside trees.
Sap comes from inside trees.
If you want to specify a person/thing in a tree, on a specific part of the tree, us 'on':
The boy is sitting on the branch in the tree.
There's a colourful caterpillar on the leaf in the tree.
Both 'on the branch' and 'in the tree' are referring to 'the boy'.
Similarly with the caterpillar.