public IDictionary <string, object> FlattenDictionary()
        {
            Dictionary <string, object> toUpdate = new Dictionary <string, object>();

            if (IsLeaf)
            {
                toUpdate.Add("value", ((DataLeaf)this).Value);
            }
            else
            {
                DataBranch branch = (DataBranch)this;
                foreach (var item in branch.Keys)
                {
                    var child = branch[item];
                    if (child.IsLeaf)
                    {
                        toUpdate[item] = ((DataLeaf)child).Value;
                    }
                    else
                    {
                        foreach (var childItem in child.FlattenDictionary())
                        {
                            toUpdate[item + "/" + childItem.Key] = childItem.Value;
                        }
                    }
                }
            }

            return(toUpdate);
        }
 public override void Merge(DataBranch data)
 {
     if (data.IsLeaf)
     {
         throw new NotImplementedException();
     }
     foreach (var item in data)
     {
         if (ContainsKey(item.Key))
         {
             if (item.Value == null)
             {
                 //i think this neve happens.
                 children.Remove(item.Key);
             }
             else
             {
                 if (children[item.Key].IsLeaf != item.Value.IsLeaf || item.Value.IsLeaf)
                 {
                     //this might override the leaf with a new one with the same value.
                     children[item.Key] = item.Value;
                 }
                 else
                 {
                     //i can only get here if i have two branches to merge.
                     children[item.Key].AsBranch().Merge(item.Value.AsBranch());
                 }
             }
         }
         else
         {
             if (item.Value != null)
             {
                 children[item.Key] = item.Value;
             }
         }
     }
 }
 public abstract void Merge(DataBranch data);
 public override void Merge(DataBranch data)
 {
     throw new NotImplementedException();
 }