It is legal to trim your neighbor's tree branches that overhang into your yard, but there are CA Civil Code Sec.3346 rules that apply.
What can I do about overhanging branches from a neighbor’s tree?By law, you have the right to trim tree branches that extend into your property line. However, it is good practice to bring up the issue with your neighbor first. Give them a chance to take care of the trimming themselves, and/or offer to do it if they prefer.
Keep in mind that California has very strict laws regarding tree trimming. Under section 3346 of the California Civil Code, a person may not cut or remove any part of a tree that does not overhang their property. If you cause the tree to die or cause so much damage that its value is destroyed, you may be held financially responsible.
Neighbor disputs about branch and root trimming are civil matters and are not something that the City will address. However, the City's municipal code, section 17.62, regulates tree removal in certain districts.
Please talk to your neighbor before trimming branches or roots from their trees and take into consideration monetary penalties that can be sought under California Civil Code sec. 3346 if the tree's health is damaged.