to get last common parent