func FindCommonAscendant(t1, t2 *tree.Tree) *tree.Tree {
	d1 := depth(t1)
	d2 := depth(t2)

	var tLonger, tShorter *tree.Tree
	var diff, dmin int
	if d1 > d2 {
		tLonger = t1
		tShorter = t2
		diff = d1 - d2
		dmin = d2
	} else {
		tLonger = t2
		tShorter = t1
		diff = d2 - d1
		dmin = d1
	}
	for i := 0; i < diff; i++ {
		tLonger = tLonger.Parent
	}
	for i := 0; i < dmin; i++ {
		if tLonger.Parent == tShorter.Parent {
			return tLonger.Parent
		}
	}
	return nil
}
// FindCommonAscendant solves ch04-p08

FindCommonAscendant solves ch04-p08
// FindCommonAscendant solves ch04 - p08
func FindCommonAscendant(t1, t2 *tree.Tree) *tree.Tree {
	d1 := depth(t1)
	d2 := depth(t2)
	var tLonger, tShorter *tree.Tree
	var diff, dmin int
	if d1 > d2 {
		tLonger = t1
		tShorter = t2
		diff = d1 - d2
		dmin = d2
	} else {
		tLonger = t2
		tShorter = t1
		diff = d2 - d1
		dmin = d1
	}
	for i := 0; i < diff; i++ {
		tLonger = tLonger.Parent
	}
	for i := 0; i < dmin; i++ {
		if tLonger.Parent == tShorter.Parent {
			return tLonger.Parent
		}
	}
	return nil
}
func FindCommonAscendant ( t1 , t2 * tree . Tree ) * tree . Tree { d1 := depth ( t1 ) d2 := depth ( t2 ) var tLonger , tShorter * tree . Tree var diff , dmin int if d1 > d2 { tLonger = t1 tShorter = t2 diff = d1 - d2 dmin = d2 } else { tLonger = t2 tShorter = t1 diff = d2 - d1 dmin = d1 } for i := 0 ; i < diff ; i ++ { tLonger = tLonger . Parent } for i := 0 ; i < dmin ; i ++ { if tLonger . Parent == tShorter . Parent { return tLonger . Parent } } return nil }
FindCommonAscendant solves ch04-p08
FindCommonAscendant solves ch04 - p08