nsCOMPtr<nsIDOMNode> added; if (!aBefore) { return AppendChild(aElement, getter_AddRefs(added));
nsresult result; nsIDOMNode* ret;  if (nsnull == aBefore) { result = mInner.AppendChild(aElement, &ret); NS_IF_RELEASE(ret); } else {   nsIDOMNode* parent;  result = aBefore->GetParentNode(&parent); if (NS_SUCCEEDED(result) && (nsnull != parent)) { result = parent->InsertBefore(aElement, aBefore, &ret); NS_IF_RELEASE(ret); NS_RELEASE(parent); }
nsHTMLSelectElement::Add(nsIDOMHTMLElement* aElement,                         nsIDOMHTMLElement* aBefore){  nsCOMPtr<nsIDOMNode> added;  if (!aBefore) {    return AppendChild(aElement, getter_AddRefs(added));  }  // Just in case we're not the parent, get the parent of the reference  // element  nsCOMPtr<nsIDOMNode> parent;  aBefore->GetParentNode(getter_AddRefs(parent));  if (!parent) {    // NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT    // element.    return NS_ERROR_DOM_NOT_FOUND_ERR;  }  nsCOMPtr<nsIDOMNode> ancestor(parent);  nsCOMPtr<nsIDOMNode> temp;  while (ancestor != NS_STATIC_CAST(nsIDOMNode*, this)) {    ancestor->GetParentNode(getter_AddRefs(temp));    if (!temp) {      // NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT      // element.      return NS_ERROR_DOM_NOT_FOUND_ERR;    }    temp.swap(ancestor);  }  // If the before parameter is not null, we are equivalent to the  // insertBefore method on the parent of before.  return parent->InsertBefore(aElement, aBefore, getter_AddRefs(added));}