I need to show blocks on different url's.

    Block1 
    Should be displayed on:
    branches/taxonomytermlevel1
    But not on
    branches/taxonomytermlevel1/taxonomytermlevel2
    
    Block2 
    Should be displayed on
    branches/taxonomytermlevel1/taxonomytermlevel2
    But not on
    branches/taxonomytermlevel1

The terms 
/taxonomytermlevel1/taxonomytermlevel2 are variables (elements in some taxonomy list)

What is the most easiest way to do this? I think a php script in the block display visibility setting would be the trick and so I tried some code there but I did not succeed.

Some code I have now is e.g.:

    <?php
    if (empty(arg(3))) {
      return TRUE;
    }else {
      return FALSE;
    }
    ?>

Any suggestions?