extensions/emmet/src/selectItemStylesheet.ts/nextItemStylesheet
export function nextItemStylesheet(document: vscode.TextDocument, startPosition: vscode.Position, endPosition: vscode.Position, rootNode: Node): vscode.Selection | undefined {
	const startOffset = document.offsetAt(startPosition);
	const endOffset = document.offsetAt(endPosition);
	let currentNode: CssNode | undefined = <CssNode>getFlatNode(rootNode, endOffset, true);
	if (!currentNode) {
		currentNode = <CssNode>rootNode;
	}
	if (!currentNode) {
		return;
	}
	// Full property is selected, so select full property value next
	if (currentNode.type === 'property' &&
		startOffset === currentNode.start &&
		endOffset === currentNode.end) {
		return getSelectionFromProperty(document, currentNode, startOffset, endOffset, true, 'next');
	}

	// Part or whole of propertyValue is selected, so select the next word in the propertyValue
	if (currentNode.type === 'property' &&
		startOffset >= (<Property>currentNode).valueToken.start &&
		endOffset <= (<Property>currentNode).valueToken.end) {
		const singlePropertyValue = getSelectionFromProperty(document, currentNode, startOffset, endOffset, false, 'next');
		if (singlePropertyValue) {
			return singlePropertyValue;
		}
	}

	// Cursor is in the selector or in a property
	if ((currentNode.type === 'rule' && endOffset < (<Rule>currentNode).selectorToken.end)
		|| (currentNode.type === 'property' && endOffset < (<Property>currentNode).valueToken.end)) {
		return getSelectionFromNode(document, currentNode);
	}

	// Get the first child of current node which is right after the cursor
	let nextNode = currentNode.firstChild;
	while (nextNode && endOffset >= nextNode.end) {
		nextNode = nextNode.nextSibling;
	}

	// Get next sibling of current node or the parent
	while (!nextNode && currentNode) {
		nextNode = currentNode.nextSibling;
		currentNode = currentNode.parent;
	}

	return nextNode ? getSelectionFromNode(document, nextNode) : undefined;
}