If a neighbor’s tree is encroaching onto one’s property:
Cutting the branches: One whose neighbor’s tree is encroaching into one’s property, then if it is getting in the way of one’s use of the property, then he may cut down the area of the tree that extends into his property and is of nuisance. One may not cut any part of the tree that is on his neighbor’s side of the property, even if it is of nuisance. One may not cut more than necessary to prevent the damage, even if it is encroaching onto his side of the property. The same applies towards a privately-owned tree which encroaches onto the public pathway, that its branches may be cut to allow for smooth transit.
May one keep the fruits of the tree? The determining factor of ownership of a tree is the property in which its root and trunk grow, and not where its branches extend to. Thus, in the event that a tree that grows in one property extends its branches and fruits into another property, the branches and fruit remain the property of the owner of the property in which the trunk of the tree grows. Accordingly, although it is permitted for one to cut down the encroaching branches that interfere with one’s use of the property, he does not have a right to keep the fruits of the tree, and it must be given to the owner unless he receives their explicit permission to keep the fruit. The same applies regarding the wood of the branches, that they must be given to the owner [if the owner is known to make use of them].
Cutting the roots of a neighbor’s tree: If the roots of a neighbor’s tree are growing under one’s property, it is permitted cut the roots that interfere with one’s use of the property. Thus, for example, if one is making use of a 24-centimeter ditch, then he may cut all roots that interfere with that ditch. This applies even if cutting the roots may damage the tree. The roots that are cut to be returned to the owner of the tree [if the owner has a use of them], unless the roots are a 16 Ama [8 meter] distance from the tree, in which case one may keep the roots.
The branches, fruits, and roots of a tree within 15 Amos of the tree, that encroach into one’s property, remain under the legal ownership of the tree owner. One may not take the fruits or branches for himself. Nonetheless, any area of that interferes with one’s use of his property may be cut in limitation, to accommodate that use.
While each State in the USA contains their own codes and laws regarding neighbors and trees, the general legal practice follows similar guidelines as those given by Halacha, with a few exceptions. The laws: a) One may trim all the branches of the tree that extend into one’s property, up until the property line. [According to Halacha, however, one may only cut the areas that interfere.] b) The fruits of the branches that extend into your property still belong to the owner of the tree. The owner is defined as whoever’s property grows the trunk and roots of the tree. c) You cannot cut the parts of the tree that are in your neighbor’s property even if the leaves and debris of the tree fly into your yard and are a nuisance to your property. d) One may not cut the roots of a tree that encroach into one’s property if it will damage the tree. [According to Halacha, this is permitted.] As practical advice always try to first resolve the issue with your neighbor, and if necessary seek legal counsel in your state.
 Michaber C.M. 155:26; Mishneh Bava Basra 27b
 See Michaber and Mishneh ibid “He may cut the tree up until the point where the stick of the plow reaches.” Smeh 155:64 “So it does not interfere with his plow” Michaber and Mishneh ibid “If it is a carob or fig tree which gives lots of shade, it may be cut down up until the border of one’s property.” Smeh 155:65 “As its shade is plentiful [and prevents sun from reaching the field]” Michaber 155:28 “If the branches of a tree encroach onto one’s roof and prevent him from repairing or renovating it, he may cut it down.”
 The reason: As the Torah gave permission for the victim to cut from the tree as much as necessary to remove the damage. [Smeh 155:66]
 See Michaber and Mishneh ibid “Until the border”
 See previous footnotes
 Michaber 155:27; Mishneh Bava Basra 27b
 Rama 167:2 “However, if the tree grows in one property and encroaches onto another property , we follow the trunk, and it is all his”; Michaber 155:29 and 167:2 that even if the tree is in the middle of the border and equally belongs to both of them, one may not take the fruit from the branches that extends into his property, and rather it must be equally divided. Hence, we see that the fruits always remain the property of the owner. See also Michaber 155:30 “If the roots are within a 16 Ama distance from the tree he may cut it and give it to the owner.”; Bava Metzia 197a
 Michaber 155:30; Bava Basra 26a