private bool TryGetMetadataForNode(TreeNodeBase <T> node, string key, out object metadata)
        {
            metadata = null;

            var state = _contextState.GetState();

            if (state != null)
            {
                var contextKey = GetContextKey(node, key);
                if (state.ContainsKey(contextKey))
                {
                    metadata = state[contextKey];
                    return(true);
                }
            }

            if (node._metadata != null && node._metadata.ContainsKey(key))
            {
                metadata = node._metadata[key];
                return(true);
            }

            return(false);
        }
 private static string GetContextKey(TreeNodeBase <T> node, string key)
 {
     return(node.GetHashCode().ToString() + key);
 }