code: function findInsertIdx(children, after) {
      var childrenTags = children.map(function(child) { return child.tag; });
      var afters = after.split(';');
      var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); });
      var foundIndex = _.find(afterIndexes, function(index) { return index != -1; });
  
      //add to the beginning if no matching nodes are found
      return typeof foundIndex === 'undefined' ? 0 : foundIndex+1;
  }
docs: Find the index at which to insert an entry. After is a ;-separated priority list of tags after which the insertion should be made. E.g. If we need to insert an element C, and the rule is that the order of children has to be As, Bs, Cs. After will be equal to "C;B;A".