Dealt with a neighbor tree damage situation that escalated to litigation, so I want to share what I learned about the law in this area. Tree law is actually more nuanced than most people realize, and the rules vary significantly by state.
The general common law rule is that you have the right to trim branches and roots that encroach onto your property, but only up to your property line. You cannot enter the neighbor property to do so, and you must not kill the tree in the process. However, when a neighbor tree causes actual damage to your property -- foundation cracks, broken fences, roof damage, sewer line infiltration -- the analysis shifts from self-help trimming to liability for damages.
In most states, the tree owner is liable for damage caused by their tree if they had notice of the hazardous condition and failed to address it. Notice can be actual (you told them the tree was leaning over your roof) or constructive (the hazard was obvious to anyone). Some states like California follow a strict liability approach for tree owner damage under Civil Code Section 833, while others require proof of negligence.
In my case, my neighbor large oak had been dropping massive limbs onto my property for two years. I documented every incident with photos and sent three certified letters asking the neighbor to trim or remove the tree. When a major limb fell and damaged my roof, causing 18,000 dollars in repair costs, I filed a claim with my homeowner insurance. My insurer paid the claim and then subrogated against the neighbor (meaning they pursued the neighbor for reimbursement).
Key tip: always send written notice to the neighbor about the tree hazard. Email is fine, but certified mail is better. This establishes the notice element that you will need if the situation escalates to a claim. Keep copies of all photos, correspondence, and repair estimates. If the tree is on HOA common area, the notice should go to the HOA board in writing, as the HOA has a duty to maintain common area vegetation and can be liable for damage caused by their failure to do so.