function addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
{
	var patch = patches[i];
	var index = patch.index;

	while (index === low)
	{
		var patchType = patch.type;

		if (patchType === 'p-thunk')
		{
			addDomNodes(domNode, vNode.node, patch.data, eventNode);
		}
		else if (patchType === 'p-reorder')
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;

			var subPatches = patch.data.patches;
			if (subPatches.length > 0)
			{
				addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
			}
		}
		else if (patchType === 'p-remove')
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;

			var data = patch.data;
			if (typeof data !== 'undefined')
			{
				data.entry.data = domNode;
				var subPatches = data.patches;
				if (subPatches.length > 0)
				{
					addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
				}
			}
		}
		else
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;
		}

		i++;

		if (!(patch = patches[i]) || (index = patch.index) > high)
		{
			return i;
		}
	}

	switch (vNode.type)
	{
		case 'tagger':
			var subNode = vNode.node;

			while (subNode.type === "tagger")
			{
				subNode = subNode.node;
			}

			return addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, domNode.elm_event_node_ref);

		case 'node':
			var vChildren = vNode.children;
			var childNodes = domNode.childNodes;
			for (var j = 0; j < vChildren.length; j++)
			{
				low++;
				var vChild = vChildren[j];
				var nextLow = low + (vChild.descendantsCount || 0);
				if (low <= index && index <= nextLow)
				{
					i = addDomNodesHelp(childNodes[j], vChild, patches, i, low, nextLow, eventNode);
					if (!(patch = patches[i]) || (index = patch.index) > high)
					{
						return i;
					}
				}
				low = nextLow;
			}
			return i;

		case 'keyed-node':
			var vChildren = vNode.children;
			var childNodes = domNode.childNodes;
			for (var j = 0; j < vChildren.length; j++)
			{
				low++;
				var vChild = vChildren[j]._1;
				var nextLow = low + (vChild.descendantsCount || 0);
				if (low <= index && index <= nextLow)
				{
					i = addDomNodesHelp(childNodes[j], vChild, patches, i, low, nextLow, eventNode);
					if (!(patch = patches[i]) || (index = patch.index) > high)
					{
						return i;
					}
				}
				low = nextLow;
			}
			return i;

		case 'text':
		case 'thunk':
			throw new Error('should never traverse `text` or `thunk` nodes like this');
	}
}
// assumes `patches` is non-empty and indexes increase monotonically.
assumes `patches` is non-empty and indexes increase monotonically.
assumes ` patches ` is non - empty and indexes increase monotonically .
function addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
{
	var patch = patches[i];
	var index = patch.index;
	while (index === low)
	{
		var patchType = patch.type;
		if (patchType === 'p-thunk')
		{
			addDomNodes(domNode, vNode.node, patch.data, eventNode);
		}
		else if (patchType === 'p-reorder')
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;
			var subPatches = patch.data.patches;
			if (subPatches.length > 0)
			{
				addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
			}
		}
		else if (patchType === 'p-remove')
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;
			var data = patch.data;
			if (typeof data !== 'undefined')
			{
				data.entry.data = domNode;
				var subPatches = data.patches;
				if (subPatches.length > 0)
				{
					addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
				}
			}
		}
		else
		{
			patch.domNode = domNode;
			patch.eventNode = eventNode;
		}
		i++;
		if (!(patch = patches[i]) || (index = patch.index) > high)
		{
			return i;
		}
	}
	switch (vNode.type)
	{
		case 'tagger':
			var subNode = vNode.node;
			while (subNode.type === "tagger")
			{
				subNode = subNode.node;
			}
			return addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, domNode.elm_event_node_ref);
		case 'node':
			var vChildren = vNode.children;
			var childNodes = domNode.childNodes;
			for (var j = 0; j < vChildren.length; j++)
			{
				low++;
				var vChild = vChildren[j];
				var nextLow = low + (vChild.descendantsCount || 0);
				if (low <= index && index <= nextLow)
				{
					i = addDomNodesHelp(childNodes[j], vChild, patches, i, low, nextLow, eventNode);
					if (!(patch = patches[i]) || (index = patch.index) > high)
					{
						return i;
					}
				}
				low = nextLow;
			}
			return i;
		case 'keyed-node':
			var vChildren = vNode.children;
			var childNodes = domNode.childNodes;
			for (var j = 0; j < vChildren.length; j++)
			{
				low++;
				var vChild = vChildren[j]._1;
				var nextLow = low + (vChild.descendantsCount || 0);
				if (low <= index && index <= nextLow)
				{
					i = addDomNodesHelp(childNodes[j], vChild, patches, i, low, nextLow, eventNode);
					if (!(patch = patches[i]) || (index = patch.index) > high)
					{
						return i;
					}
				}
				low = nextLow;
			}
			return i;
		case 'text':
		case 'thunk':
			throw new Error('should never traverse `text` or `thunk` nodes like this');
	}
}
function addDomNodesHelp ( domNode , vNode , patches , i , low , high , eventNode ) { var patch = patches [ i ] ; var index = patch . index ; while ( index === low ) { var patchType = patch . type ; if ( patchType === 'p-thunk' ) { addDomNodes ( domNode , vNode . node , patch . data , eventNode ) ; } else if ( patchType === 'p-reorder' ) { patch . domNode = domNode ; patch . eventNode = eventNode ; var subPatches = patch . data . patches ; if ( subPatches . length > 0 ) { addDomNodesHelp ( domNode , vNode , subPatches , 0 , low , high , eventNode ) ; } } else if ( patchType === 'p-remove' ) { patch . domNode = domNode ; patch . eventNode = eventNode ; var data = patch . data ; if ( typeof data !== 'undefined' ) { data . entry . data = domNode ; var subPatches = data . patches ; if ( subPatches . length > 0 ) { addDomNodesHelp ( domNode , vNode , subPatches , 0 , low , high , eventNode ) ; } } } else { patch . domNode = domNode ; patch . eventNode = eventNode ; } i ++ ; if ( ! ( patch = patches [ i ] ) || ( index = patch . index ) > high ) { return i ; } } switch ( vNode . type ) { case 'tagger' : var subNode = vNode . node ; while ( subNode . type === "tagger" ) { subNode = subNode . node ; } return addDomNodesHelp ( domNode , subNode , patches , i , low + 1 , high , domNode . elm_event_node_ref ) ; case 'node' : var vChildren = vNode . children ; var childNodes = domNode . childNodes ; for ( var j = 0 ; j < vChildren . length ; j ++ ) { low ++ ; var vChild = vChildren [ j ] ; var nextLow = low + ( vChild . descendantsCount || 0 ) ; if ( low <= index && index <= nextLow ) { i = addDomNodesHelp ( childNodes [ j ] , vChild , patches , i , low , nextLow , eventNode ) ; if ( ! ( patch = patches [ i ] ) || ( index = patch . index ) > high ) { return i ; } } low = nextLow ; } return i ; case 'keyed-node' : var vChildren = vNode . children ; var childNodes = domNode . childNodes ; for ( var j = 0 ; j < vChildren . length ; j ++ ) { low ++ ; var vChild = vChildren [ j ] . _1 ; var nextLow = low + ( vChild . descendantsCount || 0 ) ; if ( low <= index && index <= nextLow ) { i = addDomNodesHelp ( childNodes [ j ] , vChild , patches , i , low , nextLow , eventNode ) ; if ( ! ( patch = patches [ i ] ) || ( index = patch . index ) > high ) { return i ; } } low = nextLow ; } return i ; case 'text' : case 'thunk' : throw new Error ( 'should never traverse `text` or `thunk` nodes like this' ) ; } }
assumes `patches` is non-empty and indexes increase monotonically.
assumes ` patches ` is non - empty and indexes increase monotonically .