///<summary>
 /// Print the inventory tree retrieved from
 /// the PropertyCollector
 ///</summary>
 private static void printInventoryTree(ObjectContent[] ocs)
 {
     // Hashtable MoRef.Value -> MeNode
     Hashtable nodes = new Hashtable();
     // The root folder node
     MeNode root = null;
     for (int oci = 0; oci < ocs.Length; ++oci)
     {
         ObjectContent oc = ocs[oci];
         ManagedObjectReference mor = oc.obj;
         DynamicProperty[] dps = oc.propSet;
         if (dps != null)
         {
             ManagedObjectReference parent = null;
             String name = null;
             for (int dpi = 0; dpi < dps.Length; ++dpi)
             {
                 DynamicProperty dp = dps[dpi];
                 if (dp != null)
                 {
                     if ("name".Equals(dp.name))
                     {
                         name = (String)dp.val;
                     }
                     if ("parent".Equals(dp.name))
                     {
                         parent = (ManagedObjectReference)dp
                         .val;
                     }
                 }
             }
             // Create a MeNode to hold the data
             MeNode node = new MeNode(parent, mor, name);
             // The root folder has no parent
             if (parent == null)
             {
                 root = node;
             }
             // Add the node
             nodes.Add(node.getNode().Value, node);
         }
     }
     // Build the nodes into a tree
     foreach (String key in nodes.Keys)
     {
         MeNode meNode = nodes[key] as MeNode;
         if (meNode.getParent() != null)
         {
             MeNode parent = (MeNode)nodes[meNode.getParent().Value];
             parent.getChildren().Add(meNode);
         }
     }
     Console.WriteLine("Inventory Tree");
     printNode(root, 0);
 }
 ///<summary>
 /// Recursive method to print an inventory tree node
 ///</summary>
 private static void printNode(MeNode node, int indent)
 {
     // Make it pretty
     for (int i = 0; i < indent; ++i)
     {
         Console.Write(' ');
     }
     Console.WriteLine(node.getName() +
             " (" + node.getNode().type + ")");
     if (node.getChildren().Count != 0)
     {
         for (int c = 0; c < node.getChildren().Count; ++c)
         {
             printNode((MeNode)
                     node.getChildren()[c], indent + 2);
         }
     }
 }