вообще-то от что получилось
<body>
<div>
<div id="multi-parent">
<div>
<div id="firstChild"></div>
</div>
<div>
<div>
<div id="secondChild"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var $ = function(n){return document.getElementById(n);}
var getParent = function(fe,se){
var parentF = fe.parentNode;
while(true)
if(parentTest(se,parentF)) return parentF;
else parentF=parentF.parentNode;
return document.body;
}
function parentTest(child,parent){
while(true){
if(child.parentNode==parent) return true;
else
if(child.parentNode!=document.body) child=child.parentNode;
else break;
}
return false;
}
alert(getParent($("firstChild"),$("secondChild")).id);
</script>
</body>