Index: trunk/include/regfi.h
===================================================================
--- trunk/include/regfi.h	(revision 251)
+++ trunk/include/regfi.h	(revision 252)
@@ -1013,5 +1013,5 @@
  * Adds an extra internal reference to specified record, making it necessary to
  * call regfi_free_record on it an additional time before it is freed.  This is
- * useful in cases where multiple threads/structures need access to a record, 
+ * useful in cases where multiple threads/structures need access to a shared record,
  * without requiring them to be in sync with when it is freed.
  *
@@ -1022,10 +1022,16 @@
  *        REGFI_SK, REGFI_DATA, and REGFI_CLASSNAME records.
  *
- * @return true on success, false otherwise
- *
- * @ingroup regfiBase
- */
-_EXPORT()
-bool regfi_reference_record(REGFI_FILE* file, const void* record);
+ * @return Updated record pointer on success, NULL otherwise
+ *
+ * @note Be sure to use the returned record for further access to the structure
+ *       instead of the previous version of the pointer.  E.g.:
+ *       @code 
+ *       myKey = (const REGFI_NK*)regfi_reference_record(myFile, myKey);
+ *       @endcode
+ *
+ * @ingroup regfiBase
+ */
+_EXPORT()
+const void* regfi_reference_record(REGFI_FILE* file, const void* record);
 
 
@@ -1289,5 +1295,5 @@
  */
 _EXPORT()
-bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path);
+bool regfi_iterator_descend(REGFI_ITERATOR* i, const char** path);
 
 
@@ -1413,6 +1419,5 @@
 
 
-/** Returns the full path where the iterator is currently located as a list 
- *  of NK records
+/** Returns the current key and all parent keys as a list of NK records
  *
  * @param i     the iterator
@@ -1420,5 +1425,5 @@
  * @return An array of NK record pointers terminated by a NULL pointer.  
  *         This array may be passed directly to regfi_free_record to free
- *         the entire array.  
+ *         the entire array.
  *
  * @note In order to use an element of the array independently from the 
@@ -1430,5 +1435,5 @@
  */
 _EXPORT()
-const REGFI_NK** regfi_iterator_cur_path(REGFI_ITERATOR* i);
+const REGFI_NK** regfi_iterator_ancestry(REGFI_ITERATOR* i);
 
 
Index: trunk/lib/lru_cache.c
===================================================================
--- trunk/lib/lru_cache.c	(revision 251)
+++ trunk/lib/lru_cache.c	(revision 252)
@@ -260,7 +260,7 @@
     ht->table[hash] = e;
   }
+  if(ht->talloc_data)
+    data = talloc_reference(e, data);
   e->data = data;
-  if(ht->talloc_data)
-    talloc_reference(e, e->data);
 
   /* Finally, let's insert the element to the newest position in the LRU list.*/
Index: trunk/lib/regfi.c
===================================================================
--- trunk/lib/regfi.c	(revision 251)
+++ trunk/lib/regfi.c	(revision 252)
@@ -1799,12 +1799,12 @@
 /******************************************************************************
  *****************************************************************************/
-bool regfi_reference_record(REGFI_FILE* file, const void* record)
-{
-  bool ret_val = false;
+const void* regfi_reference_record(REGFI_FILE* file, const void* record)
+{
+  const void* ret_val = NULL;
+
   if(!regfi_lock(file, &file->mem_lock, "regfi_reference_record"))
     return ret_val;
-  
-  if(talloc_reference(NULL, record) != NULL)
-    ret_val = true;
+
+  ret_val = talloc_reference(NULL, record);
 
   regfi_unlock(file, &file->mem_lock, "regfi_reference_record");
@@ -1933,7 +1933,4 @@
   if(subkey == NULL)
   {
-    regfi_log_add(REGFI_LOG_WARN, "Could not obtain cur_subkey during"
-                  " iterator_down with subkey index (%d) and key offset=%.8X\n",
-                  i->cur->cur_subkey, i->cur->offset);
     talloc_free(pos);
     return false;
@@ -2026,5 +2023,5 @@
 /******************************************************************************
  *****************************************************************************/
-bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path)
+bool regfi_iterator_descend(REGFI_ITERATOR* i, const char** path)
 {
   uint32_t x;
@@ -2175,5 +2172,5 @@
 /******************************************************************************
  *****************************************************************************/
-const REGFI_NK** regfi_iterator_cur_path(REGFI_ITERATOR* i)
+const REGFI_NK** regfi_iterator_ancestry(REGFI_ITERATOR* i)
 {
   REGFI_NK** ret_val;
@@ -2203,5 +2200,5 @@
   void_stack_iterator_free(iter);
 
-  if(!regfi_lock(i->f, &i->f->mem_lock, "regfi_cur_path"))
+  if(!regfi_lock(i->f, &i->f->mem_lock, "regfi_iterator_ancestry"))
   {
     talloc_free(ret_val);
@@ -2212,5 +2209,5 @@
     talloc_reparent(NULL, ret_val, ret_val[k]);
 
-  regfi_unlock(i->f, &i->f->mem_lock, "regfi_cur_path");
+  regfi_unlock(i->f, &i->f->mem_lock, "regfi_iterator_ancestry");
 
   ret_val[k] = NULL;
Index: trunk/python/pyregfi/__init__.py
===================================================================
--- trunk/python/pyregfi/__init__.py	(revision 251)
+++ trunk/python/pyregfi/__init__.py	(revision 252)
@@ -174,5 +174,5 @@
     i = 0
     s = chars_pointer[i]
-    while s != None:
+    while s:
         ret_val.append(s.decode('utf-8', 'replace'))
         i += 1
@@ -180,4 +180,5 @@
 
     return ret_val
+
 
 
@@ -316,9 +317,10 @@
             raise Exception("Could not create _GenericList; key is NULL."
                             + "Current log:\n" + getLogMessages())
-        
-        if not regfi.regfi_reference_record(key._hive.file, key._base):
+
+        base = regfi.regfi_reference_record(key._hive.file, key._base)
+        if not base:
             raise Exception("Could not create _GenericList; memory error."
                             + "Current log:\n" + getLogMessages())
-        self._key_base = key._base
+        self._key_base = cast(base, type(key._base))
         self._length = self._fetch_num(self._key_base)
         self._hive = key._hive
@@ -461,5 +463,5 @@
             ret_val = super(Key, self).__getattr__(name)
 
-            if ret_val == None:
+            if not ret_val:
                 ret_val = self.name_raw
             else:
@@ -624,5 +626,5 @@
         ret_val = super(Value, self).__getattr__(name)
         if name == "name":
-            if ret_val == None:
+            if not ret_val:
                 ret_val = self.name_raw
             else:
@@ -984,5 +986,4 @@
         return ret_val
 
-
     ## Traverse downward multiple levels
     #
@@ -996,9 +997,39 @@
 
         self._lock.acquire()
-        result = regfi.regfi_iterator_walk_path(self._iter, cpath)
+        result = regfi.regfi_iterator_descend(self._iter, cpath)
         self._lock.release()
         if not result:
             # XXX: Use non-generic exception
             raise Exception('Could not locate path.\n'+getLogMessages())
+
+    ## Obtains a list of the current key's ancestry
+    #
+    # @return A list of all parent keys starting with the root Key and ending
+    #         with the current Key
+    def ancestry(self):
+        self._lock.acquire()
+        result = regfi.regfi_iterator_ancestry(self._iter)
+        self._lock.release()
+
+        ret_val = []
+        i = 0
+        k = result[i]
+        while k:
+            k = cast(regfi.regfi_reference_record(self._hive.file, k), POINTER(REGFI_NK))
+            ret_val.append(Key(self._hive, k))
+            i += 1
+            k = result[i]
+
+        regfi.regfi_free_record(self._hive.file, result)
+        return ret_val
+
+    ## Obtains the current path of the iterator
+    #
+    # @return A list of key names starting with the root up to and
+    #         including the current key
+    #
+    def current_path(self):
+        ancestry = self.ancestry()
+        return [str(a.name) for a in ancestry]
 
 
Index: trunk/python/pyregfi/structures.py
===================================================================
--- trunk/python/pyregfi/structures.py	(revision 251)
+++ trunk/python/pyregfi/structures.py	(revision 252)
@@ -20,10 +20,7 @@
 
 REGFI_DATA_TYPE = c_uint32
-
+REGFI_NTTIME = c_uint64
 
 # Prototype everything first so we don't have to worry about reference order
-class REGFI_NTTIME(Structure):
-    pass
-
 class REGFI_VK(Structure):
     pass
@@ -97,7 +94,4 @@
 read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t, use_errno=True)
 
-
-REGFI_NTTIME._fields_ = [('low', c_uint32),
-                         ('high', c_uint32)]
 
 REGFI_VK._fields_ = [('offset', c_uint32),
@@ -253,5 +247,5 @@
 
 regfi.regfi_reference_record.argtypes = [POINTER(REGFI_FILE), c_void_p]
-regfi.regfi_reference_record.restype = c_bool
+regfi.regfi_reference_record.restype = c_void_p
 
 regfi.regfi_fetch_num_subkeys.argtypes = [POINTER(REGFI_NK)]
@@ -307,6 +301,6 @@
 regfi.regfi_iterator_to_root.restype = c_bool
 
-regfi.regfi_iterator_walk_path.argtypes = [POINTER(REGFI_ITERATOR), POINTER(c_char_p)]
-regfi.regfi_iterator_walk_path.restype = c_bool
+regfi.regfi_iterator_descend.argtypes = [POINTER(REGFI_ITERATOR), POINTER(c_char_p)]
+regfi.regfi_iterator_descend.restype = c_bool
 
 regfi.regfi_iterator_cur_key.argtypes = [POINTER(REGFI_ITERATOR)]
@@ -337,4 +331,6 @@
 regfi.regfi_iterator_find_value.restype = c_bool
 
+regfi.regfi_iterator_ancestry.argtypes = [POINTER(REGFI_ITERATOR)]
+regfi.regfi_iterator_ancestry.restype = POINTER(POINTER(REGFI_NK))
 
 regfi.regfi_init.argtypes = []
Index: trunk/src/reglookup.c
===================================================================
--- trunk/src/reglookup.c	(revision 251)
+++ trunk/src/reglookup.c	(revision 252)
@@ -227,5 +227,5 @@
   buf[0] = '\0';
 
-  path = regfi_iterator_cur_path(i);
+  path = regfi_iterator_ancestry(i);
   if(path == NULL)
   {
@@ -381,6 +381,5 @@
 
   root = regfi_iterator_cur_key(iter);
-  regfi_reference_record(iter->f, root);
-  cur = root;
+  cur = root = regfi_reference_record(iter->f, root);
   regfi_iterator_first_subkey(iter);
   sub = regfi_iterator_cur_subkey(iter);
@@ -504,5 +503,5 @@
   }
 
-  if(!regfi_iterator_walk_path(iter, tmp_path))
+  if(!regfi_iterator_descend(iter, tmp_path))
   {
     printMsgs(iter->f);
