walk a thin line
To navigate or strike a balance between two sides, positions, or approaches to something, especially when trying to avoid one of them. The film walks a thin line between parody and homage. As a new parent, you have to walk a thin line between looking out for your child's welfare and being overprotective.
tread/walk a fine/thin ˈline
be in a difficult or dangerous situation where you could easily make a mistake: He was walking a fine line between being funny and being rude.