AlloyUI: How to get the parent in TreeViewDD

If you are using the AlloyUI TreeViewDD component to visualize a hierarchic structure, you might come to the point that you want to process the information that is created when you drag and drop items in your tree. One question that kept bugging me for days was how to get the information that Node A was dropped into Node B.
Well, here is the solution:

var tree1 = new A.TreeViewDD({
  boundingBox : '#tree1',
  children : children,
  on: {
    drop: function(event) {
      var selectedNode = tree1.getNodeById(selected);
      var parent = selectedNode.get('parentNode');
      var parentId = parent.get('id');
    lastSelectedChange: function(event){
      var id = event.newVal.get('id');
      selected = id;

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.