Finds the kth ancestor of a node in a JSON object