lca     :: Int -> [Int] -> Int
lca w xs | x == y    = x
         | w == 0    = lca y [x, y]
         | y == 0    = lca w [parent x, w]
         | otherwise = lca w [x, parent y]
         where x = head xs
               y = last xs
lca     :: Int -> [Int] -> Int
lca w xs | x == y    = x
         | w == 0    = lca y [x, y]
         | y == 0    = lca w [parent x, w]
         | otherwise = lca w [x, parent y]
         where x = head xs
               y = last xs
lca w xs | x == y    = x
         | w == 0    = lca y [x, y]
         | y == 0    = lca w [parent x, w]
         | otherwise = lca w [x, parent y]
         where x = head xs
               y = last xs