/**
  * Collapse the given fold if it's expanded and expand it if it's collapsed.
  *
  * <p><b>Note:</b> The hierarchy must be locked prior using of this method.
  *
  * @param f fold which state should be toggled.
  */
 public void toggle(Fold f) {
   if (f.isCollapsed()) {
     expand(f);
   } else { // expanded
     collapse(f);
   }
 }
 /**
  * Collapse the given fold. <br>
  * Nothing is done if the fold is already collapsed.
  *
  * <p><b>Note:</b> The hierarchy must be locked prior using of this method.
  *
  * @param f fold to be collapsed.
  */
 public void collapse(Fold f) {
   collapse(Collections.singletonList(f));
 }