if(aRecurse && (aRequestor != child)) { PRInt32 childType; child->GetItemType(&childType);
if(treeItem) CallQueryInterface(treeItem.get(), &aResult);
NS_IMETHODIMP nsWebShell::FindChildWithName(const PRUnichar *aName,    PRBool aRecurse, nsIDocShellTreeItem* aRequestor,    nsIDocShellTreeItem **_retval){   NS_ENSURE_ARG(aName);   NS_ENSURE_ARG_POINTER(_retval);     *_retval = nsnull;  // if we don't find one, we return NS_OK and a null result    nsAutoString name(aName);   nsXPIDLString childName;   PRInt32 i, n = mChildren.Count();   for(i = 0; i < n; i++)       {      nsIDocShellTreeItem* child = (nsIDocShellTreeItem*) mChildren.ElementAt(i); // doesn't addref the result      NS_ENSURE_TRUE(child, NS_ERROR_FAILURE);      child->GetName(getter_Copies(childName));      if(name.Equals(childName))         {         *_retval = child;         NS_ADDREF(child);         break;         }      if(aRecurse && (aRequestor != child)) // Only ask the child if it isn't the requestor         {         PRInt32 childType;         child->GetItemType(&childType);         if(childType == mItemType) //Only ask it to check children if it is same type            {            // See if child contains the shell with the given name            nsCOMPtr<nsIDocShellTreeNode> childAsNode(do_QueryInterface(child));            if(child)               {               NS_ENSURE_SUCCESS(childAsNode->FindChildWithName(aName, PR_TRUE,                  NS_STATIC_CAST(nsIDocShellTreeItem*, this), _retval),                  NS_ERROR_FAILURE);               }            }         }      if(*_retval)   // found it         return NS_OK;      }   return NS_OK;}