nsCOMPtr<nsIContent> cParent; PRInt32 cIndex; cN->GetParent(*getter_AddRefs(cParent)); while (cParent) { cParent->IndexOf(cN, cIndex); if (cIndex>1) { cIndex -= 2; cParent->ChildAt(cIndex, *getter_AddRefs(*ioNextNode)); return NS_OK; } cN = cParent; cN->GetParent(*getter_AddRefs(cParent)); }  return  NS_ERROR_FAILURE;
return GetPrevSibling(cN, ioNextNode);
nsresult nsContentIterator::PrevNode(nsCOMPtr<nsIContent> *ioNextNode){  if (!ioNextNode)    return NS_ERROR_NULL_POINTER;      nsCOMPtr<nsIContent> cN = *ioNextNode;   PRInt32 numChildren;  if (!NS_SUCCEEDED(cN->ChildCount(numChildren)))    return NS_ERROR_FAILURE;      // if it has children, prev is last child  if (numChildren)  {    cN->ChildAt(--numChildren, *getter_AddRefs(*ioNextNode));    return NS_OK;  }    // else the prev node is the previous sibling of this node,  // or prev sibling of it's parent, or prev sibling of it's grandparent,  // or.... you get the idea.  nsCOMPtr<nsIContent> cParent;   PRInt32 cIndex;  cN->GetParent(*getter_AddRefs(cParent));  while (cParent)    {    cParent->IndexOf(cN, cIndex);    if (cIndex>1)   // node has a prev sibling, that's what we want    {      cIndex -= 2;  // one for the 0 based counting, and one to get to prev sibling      cParent->ChildAt(cIndex, *getter_AddRefs(*ioNextNode));      return NS_OK;    }    cN = cParent;    cN->GetParent(*getter_AddRefs(cParent));  }    return  NS_ERROR_FAILURE; // there was no prev node}