Article Three of the United States Constitution
The Constitution makes sure that this will not happen to United States federal judges.  By saying judges "shall hold their Offices during good Behavior," Section 1 is basically allowing judges to keep their jobs for the rest of their lives.  In Article Two, Section 4, the Constitution does say that Congress can take away a judge's job  but only after being convicted in a trial, and only for "Treason, Bribery, or other High crimes and Misdemeanors."  (This is what Section 1 means by behavior that is not "good.")  In other words, the Constitution makes sure that all judges will lose their jobs for making even the slightest unpopular decision.  This denies judges the freedom to be independent, and to make the decisions that they think are fair, and makes them choose between right and reelection.