private void changeParent(TestElement newParent, GuiPackage guiPackage, JMeterTreeNode currentNode) {
JMeterTreeModel treeModel = guiPackage.getTreeModel();
JMeterTreeNode newNode = new JMeterTreeNode(newParent, treeModel);
JMeterTreeNode parentNode = (JMeterTreeNode) currentNode.getParent();
int index = parentNode.getIndex(currentNode);
treeModel.insertNodeInto(newNode, parentNode, index);
treeModel.removeNodeFromParent(currentNode);
int childCount = currentNode.getChildCount();
for (int i = 0; i < childCount; i++) {
// Using index 0 is voluntary as child is removed in next step and added to new parent
JMeterTreeNode node = (JMeterTreeNode) currentNode.getChildAt(0);