Since both children have the same parent (eventually), just compare the parents recursively, like so:
C Code:
struct Node
{
Node *parent;
int value;
};
Node *getParent(Node *childLeft, Node *childRight)
{
Node *currLeft = childLeft;
Node *currRight = childRight;
while(true)
{
//check for nulls
if((currLeft == NULL)||(currRight = NULL))
return NULL;
//check to see if the parents are the same
//if so, return the parent.
if(currLeft->parent == currRight->parent)
return currLeft->parent;
//parents aren't the same, continue up the tree
currLeft = currLeft->parent;
currRight = currRight->parent;
}
}