private void adjustSelectionToFoldingState(EditorComponent editorComponent) {
   if (isDescendantCellSelected(editorComponent)) {
     editorComponent.clearSelectionStack();
     jetbrains.mps.nodeEditor.cells.EditorCell editorCellToSelect =
         getFirstLeaf(CellConditions.SELECTABLE);
     if (editorCellToSelect != null) {
       editorComponent.changeSelection(editorCellToSelect);
       editorCellToSelect.home();
     } else {
       editorComponent.changeSelection(this);
       home();
     }
   }
 }
 @Override
 public void execute(EditorContext context) {
   EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
   editorComponent.clearSelectionStack();
   editorComponent.changeSelection(
       CellFinderUtil.findLastSelectableLeaf(EditorCell_Collection.this));
 }
  @Override
  public void execute(EditorContext context) {
    LOG.assertInCommand();
    EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
    EditorCell selectedCell = editorComponent.getSelectedCell();
    SNode anchorNode = selectedCell.getSNode();

    PasteNodeData pasteNodeData =
        CopyPasteUtil.getPasteNodeDataFromClipboard(anchorNode.getModel());
    if (pasteNodeData == null || pasteNodeData.getNodes().isEmpty()) {
      pasteNodeData =
          CopyPasteUtil.getConvertedFromClipboard(
              anchorNode.getModel(), context.getOperationContext().getProject());
      if (pasteNodeData == null) return;
    }
    List<SNode> pasteNodes = pasteNodeData.getNodes();
    Set<SReference> requireResolveReferences = pasteNodeData.getRequireResolveReferences();

    new NodePaster(pasteNodes).pasteRelative(anchorNode, myPastePlaceHint);
    ResolverComponent.getInstance()
        .resolveScopesOnly(requireResolveReferences, context.getOperationContext());

    // set selection
    editorComponent.flushEvents();
    EditorCell nodeCell = editorComponent.findNodeCell(pasteNodes.get(0));
    if (nodeCell == null) return; // after 'set reference'?
    EditorCell_Label labelCell =
        CellFinderUtil.findChildByClass(nodeCell, EditorCell_Label.class, true);

    if (labelCell != null) {
      editorComponent.changeSelection(labelCell);
    }

    if (pasteNodes.size() == 1) {
      editorComponent.pushSelection(nodeCell);
    } else {
      SelectionManager selectionManager = editorComponent.getSelectionManager();
      selectionManager.pushSelection(
          selectionManager.createRangeSelection(
              pasteNodes.get(0), pasteNodes.get(pasteNodes.size() - 1)));
    }
  }