function restoreSelectedChildren(oNode, aExpandingParents, oFirstCollapsedParent) {
		var bIsExpanded = oNode.getExpanded(),
			bNodeReferredInParents = false,
			bIncludeInExpandingParents = bIsExpanded && !!oNode.getSelectedForNodes().length,
			oFirstCollapsedParentNode = (oFirstCollapsedParent || bIsExpanded) ? oFirstCollapsedParent : oNode,
			i;

		//check if any of the expanded parents, that have references, refers the current node
		//if so - remove the reference
		for (i = 0; i < aExpandingParents.length; i++) {
			if (aExpandingParents[i].getSelectedForNodes().indexOf(oNode.getId()) !== -1) {
				bNodeReferredInParents = true;
				aExpandingParents[i].removeAssociation("selectedForNodes", oNode, true);
			}
		}

		//if the node is referred somewhere in its parents and it has a collapsed parent
		//add a reference to the node in the first collapsed parent (if it is not already there)
		if (oFirstCollapsedParentNode && bNodeReferredInParents && oFirstCollapsedParentNode !== oNode) {
			if (oFirstCollapsedParentNode.getSelectedForNodes().indexOf(oNode.getId()) === -1) {
				oFirstCollapsedParentNode.addAssociation("selectedForNodes", oNode, true);
			}
			oFirstCollapsedParentNode.$().addClass('sapUiTreeNodeSelectedParent');
		}

		//include the node in the expanding parents only if it has references to selected child nodes
		if (bIncludeInExpandingParents) {
			aExpandingParents.push(oNode);
		}

		var aNodes = oNode._getNodes();
		for (i = 0; i < aNodes.length; i++) {
			restoreSelectedChildren(aNodes[i], aExpandingParents, oFirstCollapsedParentNode);
		}

		//exclude the node from the expanding parents
		if (bIncludeInExpandingParents) {
			aExpandingParents.pop(oNode);
		}
	}
function restoreSelectedChildren(oNode, aExpandingParents, oFirstCollapsedParent) {
		var bIsExpanded = oNode.getExpanded(),
			bNodeReferredInParents = false,
			bIncludeInExpandingParents = bIsExpanded && !!oNode.getSelectedForNodes().length,
			oFirstCollapsedParentNode = (oFirstCollapsedParent || bIsExpanded) ? oFirstCollapsedParent : oNode,
			i;

		//check if any of the expanded parents, that have references, refers the current node
		//if so - remove the reference
		for (i = 0; i < aExpandingParents.length; i++) {
			if (aExpandingParents[i].getSelectedForNodes().indexOf(oNode.getId()) !== -1) {
				bNodeReferredInParents = true;
				aExpandingParents[i].removeAssociation("selectedForNodes", oNode, true);
			}
		}

		//if the node is referred somewhere in its parents and it has a collapsed parent
		//add a reference to the node in the first collapsed parent (if it is not already there)
		if (oFirstCollapsedParentNode && bNodeReferredInParents && oFirstCollapsedParentNode !== oNode) {
			if (oFirstCollapsedParentNode.getSelectedForNodes().indexOf(oNode.getId()) === -1) {
				oFirstCollapsedParentNode.addAssociation("selectedForNodes", oNode, true);
			}
			oFirstCollapsedParentNode.$().addClass('sapUiTreeNodeSelectedParent');
		}

		//include the node in the expanding parents only if it has references to selected child nodes
		if (bIncludeInExpandingParents) {
			aExpandingParents.push(oNode);
		}

		var aNodes = oNode._getNodes();
		for (i = 0; i < aNodes.length; i++) {
			restoreSelectedChildren(aNodes[i], aExpandingParents, oFirstCollapsedParentNode);
		}

		//exclude the node from the expanding parents
		if (bIncludeInExpandingParents) {
			aExpandingParents.pop(oNode);
		}
	}
function restoreSelectedChildren ( oNode , aExpandingParents , oFirstCollapsedParent ) { var bIsExpanded = oNode . getExpanded ( ) , bNodeReferredInParents = false , bIncludeInExpandingParents = bIsExpanded && ! ! oNode . getSelectedForNodes ( ) . length , oFirstCollapsedParentNode = ( oFirstCollapsedParent || bIsExpanded ) ? oFirstCollapsedParent : oNode , i ; //check if any of the expanded parents, that have references, refers the current node //if so - remove the reference for ( i = 0 ; i < aExpandingParents . length ; i ++ ) { if ( aExpandingParents [ i ] . getSelectedForNodes ( ) . indexOf ( oNode . getId ( ) ) !== - 1 ) { bNodeReferredInParents = true ; aExpandingParents [ i ] . removeAssociation ( "selectedForNodes" , oNode , true ) ; } } //if the node is referred somewhere in its parents and it has a collapsed parent //add a reference to the node in the first collapsed parent (if it is not already there) if ( oFirstCollapsedParentNode && bNodeReferredInParents && oFirstCollapsedParentNode !== oNode ) { if ( oFirstCollapsedParentNode . getSelectedForNodes ( ) . indexOf ( oNode . getId ( ) ) === - 1 ) { oFirstCollapsedParentNode . addAssociation ( "selectedForNodes" , oNode , true ) ; } oFirstCollapsedParentNode . $ ( ) . addClass ( 'sapUiTreeNodeSelectedParent' ) ; } //include the node in the expanding parents only if it has references to selected child nodes if ( bIncludeInExpandingParents ) { aExpandingParents . push ( oNode ) ; } var aNodes = oNode . _getNodes ( ) ; for ( i = 0 ; i < aNodes . length ; i ++ ) { restoreSelectedChildren ( aNodes [ i ] , aExpandingParents , oFirstCollapsedParentNode ) ; } //exclude the node from the expanding parents if ( bIncludeInExpandingParents ) { aExpandingParents . pop ( oNode ) ; } }
Removes the references inside the expanded node of its selected children, because
they are no longer needed.
@param {sap.ui.commons.TreeNode} oNode The current node to look at
@param {object} aExpandingParents Array of parents of the current node that have selectedForNodes references
@param {sap.ui.commons.TreeNode} oFirstCollapsedParent The topmost collapsed parent node of the current node
Removes the references inside the expanded node of its selected children because they are no longer needed .
Restores the selected children of the given node