}
private static Table commonAncestor(Table inputTable, Table outputTable)
{
int minLevel = min(inputTable.getDepth(), outputTable.getDepth());
Table inputAncestor = inputTable;
while (inputAncestor.getDepth() > minLevel) {
inputAncestor = inputAncestor.getParentTable();
}
Table outputAncestor = outputTable;
while (outputAncestor.getDepth() > minLevel) {
outputAncestor = outputAncestor.getParentTable();
}
while (inputAncestor != outputAncestor) {
inputAncestor = inputAncestor.getParentTable();
outputAncestor = outputAncestor.getParentTable();
}
return outputAncestor;
}