@Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    final LayoutTreeComponent treeComponent = myEditor.getLayoutTreeComponent();
    final LayoutTreeSelection selection = treeComponent.getSelection();
    final PackagingElement<?> element = selection.getElementIfSingle();
    final PackagingElementNode<?> node = selection.getNodeIfSingle();
    if (node == null || !(element instanceof ArtifactPackagingElement)) return;

    final CompositePackagingElement<?> parent = node.getParentElement(element);
    final CompositePackagingElementNode parentNode = node.getParentNode();
    if (parent == null || parentNode == null) {
      return;
    }
    if (!treeComponent.checkCanModifyChildren(parent, parentNode, Collections.singletonList(node))) return;

    treeComponent.editLayout(() -> {
      parent.removeChild(element);
      final ArtifactEditorContext context = myEditor.getContext();
      final Artifact artifact = ((ArtifactPackagingElement)element).findArtifact(context);
      if (artifact != null) {
        final CompositePackagingElement<?> rootElement = artifact.getRootElement();
        if (rootElement instanceof ArtifactRootElement<?>) {
          for (PackagingElement<?> child : rootElement.getChildren()) {
            parent.addOrFindChild(ArtifactUtil.copyWithChildren(child, context.getProject()));
          }
        }
        else {
          parent.addOrFindChild(ArtifactUtil.copyWithChildren(rootElement, context.getProject()));
        }
      }
    });
    treeComponent.rebuildTree();
  }
@Override
  public void actionPerformed(@NotNull AnActionEvent e)