A small (math) trick to make it shorter :

if the value of x is between a and b, then (x-a)*(x-b)<=0

def lowestCommonAncestor(self, root, p, q):
while (root.val-p.val)*(root.val-q.val) > 0:
if root.val > max(p.val, q.val):
root = root.left
else:
root = root.right
return root

same idea but even shorter (Python!):

def lowestCommonAncestor(self, root, p, q):
while (root.val-p.val)*(root.val-q.val) > 0:
root = (root.right, root.left)[root.val>max(p.val, q.val)]
return root