To find the parent of a context, you call parentchunk() on the relevant contextnode: parentnode = ParentChunk(currentnode); If there is no parent context, NULL is returned.