Make object go behind tree in an image plane?

Say, an arrow turning invisible on the edges of trees in an image plane of a forest. Characters too, for that matter, is there a way to set some mask where the character “disappears” behind the tree?