public void removeSelectedElements() {
    final LayoutTreeSelection selection = myTree.getSelection();
    if (!checkCanRemove(selection.getNodes())) return;

    editLayout(
        new Runnable() {
          @Override
          public void run() {
            removeNodes(selection.getNodes());
          }
        });

    myArtifactsEditor.rebuildTries();
  }
 private PackagingElementNode<?> getParentNode(final LayoutTreeSelection selection) {
   final PackagingElementNode<?> node = selection.getNodeIfSingle();
   if (node != null) {
     if (node.getFirstElement() instanceof CompositePackagingElement) {
       return node;
     }
     final PackagingElementNode<?> parent = node.getParentNode();
     if (parent != null) {
       return parent;
     }
   }
   return myTree.getRootPackagingNode();
 }