The question evaluates understanding of binary search tree properties, the lowest common ancestor concept, and competency in implementing tree algorithms while handling absent keys via sentinel or error handling.
Given the root of a binary search tree and two keys p and q, return the value of their lowest common ancestor (the deepest node whose value lies between p and q inclusive). Provide both iterative and recursive solutions, and handle the case when one or both keys may be absent by returning a sentinel or raising an error.