Ejemplo n.º 1
0
        public Tree GetParent(Tree node)
        {
            if (node is IHasParent)
            {
                return(node.Parent());
            }
            if (nodesToParents == null)
            {
                nodesToParents = new IdentityDictionary <Tree, Tree>();
            }
            if (nodesToParents.Count == 0)
            {
                FillNodesToParents(root, null);
            }
            Tree parent;

            nodesToParents.TryGetValue(node, out parent);
            return(parent);
        }