parameters: (self, p, q)
return_statement: return p
docstring: :type node: Node
          :rtype: Node
docstring_summary: :type node: Node
          :rtype: Node
docstring_tokens: : type node : Node : rtype : Node
function: def lowestCommonAncestor(self, p, q):
          """
          :type node: Node
          :rtype: Node
          """
          def depth(node):
              d = 0
              while node:
                  node = node.parent
                  d += 1
              return d
          
          p_d, q_d = depth(p), depth(q)
          while p_d > q_d:
              p = p.parent
              p_d -= 1
          while p_d < q_d:
              q = q.parent
              q_d -= 1
          while p != q:
              p = p.parent
              q = q.parent
          return p
function_tokens: def lowestCommonAncestor ( self , p , q ) : def depth ( node ) : d = 0 while node : node = node . parent d += 1 return d p_d , q_d = depth ( p ) , depth ( q ) while p_d > q_d : p = p . parent p_d -= 1 while p_d < q_d : q = q . parent q_d -= 1 while p != q : p = p . parent q = q . parent return p