python transitiveclosure