/// <summary>
		/// Gets the count of a given facet value.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="nodeset">The <see cref="Nodeset"/> from which to get the facet result.</param>
		/// <param name="propertyName">The name of the property for which to lookup the value.</param>
		/// <param name="value">The value for which to get the count.</param>
		/// <returns></returns>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		/// <exception cref="InvalidOperationException"></exception>
		public int Evaluate(IMansionContext context, Nodeset nodeset, string propertyName, string value)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (nodeset == null)
				throw new ArgumentNullException("nodeset");
			if (string.IsNullOrEmpty(propertyName))
				throw new ArgumentNullException("propertyName");
			if (value == null)
				throw new ArgumentNullException("value");

			// find the facet
			var facet = nodeset.Facets.FirstOrDefault(candidate => propertyName.Equals(candidate.PropertyName, StringComparison.OrdinalIgnoreCase));
			if (facet == null)
				throw new InvalidOperationException(string.Format("Could not find facet for property '{0}' in the given nodeset", propertyName));

			//  return the value
			return Evaluate(context, facet, value);
		}
        /// <summary>
        /// Creates the tree structure from the <paramref name="navigationItemNodeset"/>.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="navigationNode"></param>
        /// <param name="navigationItemNodeset"></param>
        /// <param name="currentPagePointer"></param>
        /// <returns></returns>
        private Leaf BuildTreeStructure(IMansionContext context, Node navigationNode, Nodeset navigationItemNodeset, NodePointer currentPagePointer)
        {
            // first sort the set by depth ASC, than order ASC
            var sortedSet = navigationItemNodeset.Nodes.OrderBy(x => x, new ComparisonComparer<Node>((x, y) =>
                                                                                                     {
                                                                                                     	// first compare on depth
                                                                                                     	var depthComparison = x.Pointer.Depth.CompareTo(y.Pointer.Depth);
                                                                                                     	if (depthComparison != 0)
                                                                                                     		return depthComparison;

                                                                                                     	// next compare on order
                                                                                                     	return x.Order.CompareTo(y.Order);
                                                                                                     }));

            // create the parent leaf
            var rootLeaf = Leaf.Create(context, navigationNode);
            var leafSet = new List<Leaf> {rootLeaf};

            // loop over the sorted set
            foreach (var leafNode in sortedSet)
            {
                // find the parent leaf
                var parentLeaf = leafSet.Single(candidate => candidate.Node.Pointer == leafNode.Pointer.Parent);

                // create the leaf
                var leaf = Leaf.Create(context, leafNode, parentLeaf);
                if (leaf == null)
                    continue;

                // add the leaf to the parent leaf
                parentLeaf.Add(leaf);

                // add the leaf to the set
                leafSet.Add(leaf);
            }

            // find the deepest node who has an internal link and is parent of or equal to the current page pointer
            var activeLeaf = ((IEnumerable<Leaf>) leafSet).Reverse().Where(x => x.HasTarget && (currentPagePointer.IsChildOf(x.TargetNode.Pointer) || currentPagePointer == x.TargetNode.Pointer)).FirstOrDefault();
            if (activeLeaf != null)
                activeLeaf.SetActive();

            // return the parent leaf
            return rootLeaf;
        }