function typeUpToCurrentChar(node, currentChar, charsTyped, originalNodeValues, resetCounter) {

            if (resetCounter) {
                originalNodeValues.counter = 0;
            }

            if (node.nodeValue !== null) {
                var originalValue =  originalNodeValues.values[originalNodeValues.counter];
                if (currentChar - charsTyped < originalValue.length) {
                    var charsToType = currentChar - charsTyped;
                    node.nodeValue = originalValue.substring(0, charsToType);
                    charsTyped += charsToType;
                } else {
                    node.nodeValue = originalValue;
                    charsTyped += originalValue.length;
                }

                originalNodeValues.counter ++;
            }

            for (var i = 0; i < node.childNodes.length; i++) {
                if (charsTyped < currentChar) {
                    charsTyped = typeUpToCurrentChar(node.childNodes[i], currentChar, charsTyped, originalNodeValues);
                } else {
                    break;
                }
            }

            return charsTyped;
        }
Recursive function that traverses a node tree and updates the nodeValue of each
text node until the total number of characters "typed" is equal to the value
of currentChar.

@param node
@param currentChar
@param charsTyped
@returns {*}