K2 function

Compute tree similarity