return result;
nsCOMPtr<nsIDOMNode> parent; aBefore->GetParentNode(getter_AddRefs(parent)); if (!parent) {   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) {   return NS_ERROR_DOM_NOT_FOUND_ERR; } temp.swap(ancestor); }    return parent->InsertBefore(aElement, aBefore, getter_AddRefs(added));
nsHTMLSelectElement::Add(nsIDOMHTMLElement* aElement, nsIDOMHTMLElement* aBefore){  nsresult result;  nsIDOMNode* ret;  if (nsnull != aBefore) {    result = mInner.AppendChild(aElement, &ret);    NS_IF_RELEASE(ret);  }  else {    // Just in case we're not the parent, get the parent of the reference    // element    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);    }  }  return result;}