public synchronized void cancel(Cancelable root) {
    root.cancelTask();
    TreeNode rootNode = findNodeInTaskTrees(root);
    if (rootNode instanceof TreeNode) {
      List children = rootNode.getChildren();
      TreeNode parentNode = rootNode.getParent();
      for (Iterator iter = children.iterator(); iter.hasNext(); ) {
        TreeNode nextNode = ((Tree)(iter.next())).getRoot();
        cancelRecursive(nextNode);
      }
      if (parentNode instanceof TreeNode) {        
        Tree.removeFromParentChildren(rootNode);
      } else {
        removeFromTaskTrees(rootNode);
      }
    }
  }