title: Prevent the same Fragment to be added multiple times in popBackStack
body: <p>My activity is composed of 3 nested Fragments. There is my <code>MainFragment</code> that is displayed by default,  <code>ProductFragment</code> that can be called from it, then <code>DetailFragment</code> can be called from <code>ProductFragment</code>.</p>
  
  <p>I can go back and forth between my <code>ProductFragment</code> and <code>DetailFragment</code>. By doing so, the popStackBack method is accumulating similar fragments. Then, if I click on the back button, It will go back through all the Fragments as many time I called them.</p>
  
  <p>What is the proper way to avoid the same Fragment to be kept in the back stack ?</p>
  
  <p><strong>EDIT :</strong> </p>
  
  <p>I firstly call my main fragment :</p>
  
  <pre><code>    if (savedInstanceState == null) {
          getFragmentManager()
              .beginTransaction()
              .add(R.id.container, new SearchFragment(), "SEARCH_TAG")
              .commit();
      }
  </code></pre>
  
  <p>Here is the code that calls the fragments from the activity :</p>
  
  <pre><code>    FragmentManager fm = getFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();
      ft.setCustomAnimations(R.animator.enter_from_bottom, R.animator.exit_to_top, R.animator.enter_from_bottom, R.animator.exit_to_top);
      ft.replace(R.id.container, new FactFragment(), "FACT_TAG");
      ft.addToBackStack("FACT_TAG");
      ft.commit();
  </code></pre>
  
  <p>Then, on back click :</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      getFragmentManager().popBackStack();
  }
  </code></pre>
  
  <p>I tried to get the tag of my current fragment and execute some specific code related to it but it doesn't work well. I also tried to <code>addToBackStack()</code> only when current Fragment wasn't already added to the backStack but it messed up my fragment view.</p>