function traverseGraph()

in 001-IntroToKubernetes/Student/Resources/Challenge 7/content-web-v2/public/js/knockout.validation.js [226:274]


	function traverseGraph(obj, context, level) {
		var objValues = [],
			val = obj.peek ? obj.peek() : obj;

		if (obj.__kv_traversed === true) { return; }

		if (context.options.deep) {
	    obj.__kv_traversed = true;
			context.flagged.push(obj);
		}

		//default level value depends on deep option.
		level = (level !== undefined ? level : context.options.deep ? 1 : -1);

		// if object is observable then add it to the list
		if (ko.isObservable(obj)) {

			//make sure it is validatable object
			if (!obj.isValid) { obj.extend({ validatable: true }); }
			context.validatables.push(obj);

			if(context.options.live && utils.isObservableArray(obj)) {
				context.subscriptions.push(obj.subscribe(function () {
					context.graphMonitor.valueHasMutated();
				}));
		}
		}

		//get list of values either from array or object but ignore non-objects
		// and destroyed objects
		if (val && !val._destroy) {
			if (utils.isArray(val)) {
			objValues = val;
			} else if (utils.isObject(val)) {
				objValues = utils.values(val);
		}
		}

		//process recurisvely if it is deep grouping
		if (level !== 0) {
			utils.forEach(objValues, function (observable) {

				//but not falsy things and not HTML Elements
				if (observable && !observable.nodeType) {
					traverseGraph(observable, context, level + 1);
				}
			});
		}
	}