diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index f27315a..0154668 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -77,6 +77,11 @@ struct GMenuTreeItem
   GMenuTreeItemType type;
 
   GMenuTreeDirectory *parent;
+
+  /* This is a helper variable, to find the real path to this item, before
+   * inlining. Useful when editing a menu to know where the item should be
+   * excluded from. */
+  GSList *removed_by_inline;
   
   gpointer       user_data;
   GDestroyNotify dnotify;
@@ -986,6 +991,46 @@ gmenu_tree_item_get_parent (GMenuTreeItem *item)
   return item->parent ? gmenu_tree_item_ref (item->parent) : NULL;
 }
 
+/* Note: the list and its content should be freed. */
+GSList *
+gmenu_tree_item_get_real_path_list (GMenuTreeItem *item)
+{
+  GSList             *result;
+  GMenuTreeItem      *real_item;
+  GMenuTreeDirectory *parent;
+
+  g_return_val_if_fail (item != NULL, NULL);
+
+  switch (gmenu_tree_item_get_type (item))
+    {
+    case GMENU_TREE_ITEM_ALIAS:
+      real_item = gmenu_tree_alias_get_item (GMENU_TREE_ALIAS (item));
+      break;
+    default:
+      real_item = gmenu_tree_item_ref (item);
+      break;
+    }
+
+  /* create the end of the path, and make sure to ref it */
+  result = g_slist_copy (item->removed_by_inline);
+  g_slist_foreach (result,
+		   (GFunc) gmenu_tree_item_ref,
+		   NULL);
+  /* we ref'ed real_item already */
+  result = g_slist_append (result, real_item);
+
+  parent = gmenu_tree_item_get_parent (item);
+  if (parent)
+    {
+      result = g_slist_concat (gmenu_tree_item_get_real_path_list (GMENU_TREE_ITEM (parent)),
+                               result);
+
+      gmenu_tree_item_unref (parent);
+    }
+
+  return result;
+}
+
 static void
 gmenu_tree_item_set_parent (GMenuTreeItem      *item,
 			    GMenuTreeDirectory *parent)
@@ -995,6 +1040,21 @@ gmenu_tree_item_set_parent (GMenuTreeItem      *item,
   item->parent = parent;
 }
 
+static void
+gmenu_tree_item_replace_parent_for_inline (GMenuTreeItem      *item,
+					   GMenuTreeDirectory *parent)
+{
+  g_return_if_fail (item != NULL);
+
+  if (item->parent)
+    {
+      item->removed_by_inline = g_slist_prepend (item->removed_by_inline,
+                                                 gmenu_tree_item_ref (item->parent));
+    }
+
+  item->parent = parent;
+}
+
 GSList *
 gmenu_tree_directory_get_contents (GMenuTreeDirectory *directory)
 {
@@ -1421,8 +1481,13 @@ gmenu_tree_alias_new (GMenuTreeDirectory *parent,
   else
     retval->aliased_item = gmenu_tree_item_ref (gmenu_tree_alias_get_item (GMENU_TREE_ALIAS (item)));
 
-  gmenu_tree_item_set_parent (GMENU_TREE_ITEM (retval->directory), NULL);
-  gmenu_tree_item_set_parent (retval->aliased_item, NULL);
+  gmenu_tree_item_set_parent (GMENU_TREE_ITEM (directory), NULL);
+  gmenu_tree_item_set_parent (item, NULL);
+
+  /* in case the aliased item was inlined, we move the data up to this alias */
+  retval->item.removed_by_inline = g_slist_prepend (item->removed_by_inline,
+                                                    gmenu_tree_item_ref (directory));
+  item->removed_by_inline = NULL;
 
   return retval;
 }
@@ -1549,6 +1614,12 @@ gmenu_tree_item_unref (gpointer itemp)
       item->user_data = NULL;
       item->dnotify   = NULL;
 
+      g_slist_foreach (item->removed_by_inline,
+                       (GFunc) gmenu_tree_item_unref,
+                       NULL);
+      g_slist_free (item->removed_by_inline);
+      item->removed_by_inline = NULL;
+
       item->parent = NULL;
 
       g_free (item);
@@ -3613,13 +3684,38 @@ get_layout_info (GMenuTreeDirectory *directory)
   iter = directory;
   while (iter != NULL)
     {
-      /* FIXME: this is broken: we might skip real parent in the
-       * XML structure, that are hidden because of inlining. */
+      GSList *removed_parents;
+      GSList *l;
+      GSList *retval = NULL;
+
       if (iter->default_layout_info != NULL)
 	{
 	  return iter->default_layout_info;
 	}
 
+      /* the parents that were removed because of inlining might have a default
+       * layout that we should use, so we cannot go straight to the current
+       * parent */
+      removed_parents = g_slist_copy (GMENU_TREE_ITEM (iter)->removed_by_inline);
+      removed_parents = g_slist_reverse (removed_parents);
+      for (l = removed_parents; l != NULL; l = l->next)
+	{
+	  GMenuTreeDirectory *parent;
+
+	  parent = l->data;
+	  if (parent->default_layout_info != NULL)
+	    {
+	      retval = parent->default_layout_info;
+	      break;
+	    }
+	}
+      g_slist_free (removed_parents);
+
+      if (retval != NULL)
+	{
+	  return retval;
+	}
+
       iter = GMENU_TREE_ITEM (iter)->parent;
     }
 
@@ -3761,14 +3857,14 @@ preprocess_layout_info_subdir_helper (GMenuTree          *tree,
           else
             {
               g_slist_foreach (subdir->subdirs,
-                               (GFunc) gmenu_tree_item_set_parent,
+                               (GFunc) gmenu_tree_item_replace_parent_for_inline,
                                directory);
               directory->subdirs = g_slist_concat (directory->subdirs,
                                                    subdir->subdirs);
               subdir->subdirs = NULL;
 
               g_slist_foreach (subdir->entries,
-                               (GFunc) gmenu_tree_item_set_parent,
+                               (GFunc) gmenu_tree_item_replace_parent_for_inline,
                                directory);
               directory->entries = g_slist_concat (directory->entries,
                                                    subdir->entries);
@@ -4013,7 +4109,7 @@ merge_subdir (GMenuTree          *tree,
       directory->contents = g_slist_append (directory->contents, header);
 
       g_slist_foreach (subdir->contents,
-                       (GFunc) gmenu_tree_item_set_parent,
+                       (GFunc) gmenu_tree_item_replace_parent_for_inline,
                        directory);
       directory->contents = g_slist_concat (directory->contents,
                                             subdir->contents);
diff --git a/libmenu/gmenu-tree.h b/libmenu/gmenu-tree.h
index 3a05eb2..4b49d3e 100644
--- a/libmenu/gmenu-tree.h
+++ b/libmenu/gmenu-tree.h
@@ -104,8 +104,9 @@ void     gmenu_tree_item_set_user_data (GMenuTreeItem   *item,
 					GDestroyNotify  dnotify);
 gpointer gmenu_tree_item_get_user_data (GMenuTreeItem   *item);
 
-GMenuTreeItemType   gmenu_tree_item_get_type   (GMenuTreeItem *item);
-GMenuTreeDirectory *gmenu_tree_item_get_parent (GMenuTreeItem *item);
+GMenuTreeItemType   gmenu_tree_item_get_type           (GMenuTreeItem *item);
+GMenuTreeDirectory *gmenu_tree_item_get_parent         (GMenuTreeItem *item);
+GSList             *gmenu_tree_item_get_real_path_list (GMenuTreeItem *item);
 
 
 GSList     *gmenu_tree_directory_get_contents          (GMenuTreeDirectory *directory);
diff --git a/python/gmenu.c b/python/gmenu.c
index 71e4e38..ebef478 100644
--- a/python/gmenu.c
+++ b/python/gmenu.c
@@ -49,6 +49,7 @@ typedef PyGMenuTreeItem PyGMenuTreeHeader;
 typedef PyGMenuTreeItem PyGMenuTreeAlias;
 
 static PyGMenuTree          *pygmenu_tree_wrap           (GMenuTree          *tree);
+static PyGMenuTreeItem      *pygmenu_tree_item_wrap      (GMenuTreeItem      *item);
 static PyGMenuTreeDirectory *pygmenu_tree_directory_wrap (GMenuTreeDirectory *directory);
 static PyGMenuTreeEntry     *pygmenu_tree_entry_wrap     (GMenuTreeEntry     *entry);
 static PyGMenuTreeSeparator *pygmenu_tree_separator_wrap (GMenuTreeSeparator *separator);
@@ -129,9 +130,9 @@ static PyObject *
 pygmenu_tree_item_get_parent (PyObject *self,
 			      PyObject *args)
 {
-  PyGMenuTreeItem      *item;
-  GMenuTreeDirectory   *parent;
-  PyGMenuTreeDirectory *retval;
+  PyGMenuTreeItem    *item;
+  GMenuTreeDirectory *parent;
+  PyGMenuTreeItem    *retval;
 
   if (args != NULL)
     {
@@ -148,18 +149,61 @@ pygmenu_tree_item_get_parent (PyObject *self,
       return Py_None;
     }
 
-  retval = pygmenu_tree_directory_wrap (parent);
+  retval = pygmenu_tree_item_wrap (GMENU_TREE_ITEM (parent));
 
   gmenu_tree_item_unref (parent);
 
   return (PyObject *) retval;
 }
 
+static PyObject *
+pygmenu_tree_item_get_real_path (PyObject *self,
+				 PyObject *args)
+{
+  PyGMenuTreeItem *item;
+  PyObject        *retval;
+  GSList          *real_path;
+  GSList          *tmp;
+
+  if (args != NULL)
+    {
+      if (!PyArg_ParseTuple (args, ":gmenu.Item.get_real_path"))
+	return NULL;
+    }
+
+  item = (PyGMenuTreeItem *) self;
+
+  retval = PyList_New (0);
+
+  real_path = gmenu_tree_item_get_real_path_list (item->item);
+
+  tmp = real_path;
+  while (tmp != NULL)
+    {
+      GMenuTreeItem *item = tmp->data;
+      PyObject      *pyitem;
+
+      pyitem = (PyObject *) pygmenu_tree_item_wrap (item);
+
+      PyList_Append (retval, pyitem);
+      Py_DECREF (pyitem);
+
+      gmenu_tree_item_unref (item);
+
+      tmp = tmp->next;
+    }
+
+  g_slist_free (real_path);
+
+  return (PyObject *) retval;
+}
+
 static struct PyMethodDef pygmenu_tree_item_methods[] =
 {
-  { "get_type",   pygmenu_tree_item_get_type,   METH_VARARGS },
-  { "get_parent", pygmenu_tree_item_get_parent, METH_VARARGS },
-  { NULL,         NULL,                         0            }
+  { "get_type",      pygmenu_tree_item_get_type,      METH_VARARGS },
+  { "get_parent",    pygmenu_tree_item_get_parent,    METH_VARARGS },
+  { "get_real_path", pygmenu_tree_item_get_real_path, METH_VARARGS },
+  { NULL,            NULL,                            0            }
 };
 
 static PyTypeObject PyGMenuTreeItem_Type = 
@@ -208,6 +252,41 @@ static PyTypeObject PyGMenuTreeItem_Type =
   (PyObject *)0,                                 /* tp_bases */
 };
 
+static PyGMenuTreeItem *
+pygmenu_tree_item_wrap (GMenuTreeItem *item)
+{
+  PyGMenuTreeItem *retval;
+
+  switch (gmenu_tree_item_get_type (item))
+    {
+    case GMENU_TREE_ITEM_DIRECTORY:
+      retval = (PyGMenuTreeItem *) pygmenu_tree_directory_wrap (GMENU_TREE_DIRECTORY (item));
+      break;
+
+    case GMENU_TREE_ITEM_ENTRY:
+      retval = (PyGMenuTreeItem *) pygmenu_tree_entry_wrap (GMENU_TREE_ENTRY (item));
+      break;
+
+    case GMENU_TREE_ITEM_SEPARATOR:
+      retval = (PyGMenuTreeItem *) pygmenu_tree_separator_wrap (GMENU_TREE_SEPARATOR (item));
+      break;
+
+    case GMENU_TREE_ITEM_HEADER:
+      retval = (PyGMenuTreeItem *) pygmenu_tree_header_wrap (GMENU_TREE_HEADER (item));
+      break;
+
+    case GMENU_TREE_ITEM_ALIAS:
+      retval = (PyGMenuTreeItem *) pygmenu_tree_alias_wrap (GMENU_TREE_ALIAS (item));
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
+  return retval;
+}
+
 static PyObject *
 pygmenu_tree_directory_get_contents (PyObject *self,
 				     PyObject *args)
@@ -235,32 +314,7 @@ pygmenu_tree_directory_get_contents (PyObject *self,
       GMenuTreeItem *item = tmp->data;
       PyObject      *pyitem;
 
-      switch (gmenu_tree_item_get_type (item))
-	{
-	case GMENU_TREE_ITEM_DIRECTORY:
-	  pyitem = (PyObject *) pygmenu_tree_directory_wrap (GMENU_TREE_DIRECTORY (item));
-	  break;
-
-	case GMENU_TREE_ITEM_ENTRY:
-	  pyitem = (PyObject *) pygmenu_tree_entry_wrap (GMENU_TREE_ENTRY (item));
-	  break;
-
-	case GMENU_TREE_ITEM_SEPARATOR:
-	  pyitem = (PyObject *) pygmenu_tree_separator_wrap (GMENU_TREE_SEPARATOR (item));
-	  break;
-
-	case GMENU_TREE_ITEM_HEADER:
-	  pyitem = (PyObject *) pygmenu_tree_header_wrap (GMENU_TREE_HEADER (item));
-	  break;
-
-	case GMENU_TREE_ITEM_ALIAS:
-	  pyitem = (PyObject *) pygmenu_tree_alias_wrap (GMENU_TREE_ALIAS (item));
-	  break;
-
-	default:
-	  g_assert_not_reached ();
-	  break;
-	}
+      pyitem = (PyObject *) pygmenu_tree_item_wrap (item);
 
       PyList_Append (retval, pyitem);
       Py_DECREF (pyitem);
@@ -474,6 +528,7 @@ pygmenu_tree_directory_getattro (PyGMenuTreeDirectory *self,
 	  return Py_BuildValue ("[sssssssss]",
 				"type",
 				"parent",
+				"real_path",
 				"contents",
 				"name",
 				"comment",
@@ -490,6 +545,10 @@ pygmenu_tree_directory_getattro (PyGMenuTreeDirectory *self,
 	{
 	  return pygmenu_tree_item_get_parent ((PyObject *) self, NULL);
 	}
+      else if (!strcmp (attr, "real_path"))
+	{
+	  return pygmenu_tree_item_get_real_path ((PyObject *) self, NULL);
+	}
       else if (!strcmp (attr, "contents"))
 	{
 	  return pygmenu_tree_directory_get_contents ((PyObject *) self, NULL);
@@ -888,6 +947,7 @@ pygmenu_tree_entry_getattro (PyGMenuTreeEntry *self,
 	  return Py_BuildValue ("[sssssssssss]",
 				"type",
 				"parent",
+				"real_path",
 				"name",
 				"comment",
 				"icon",
@@ -906,6 +966,10 @@ pygmenu_tree_entry_getattro (PyGMenuTreeEntry *self,
 	{
 	  return pygmenu_tree_item_get_parent ((PyObject *) self, NULL);
 	}
+      else if (!strcmp (attr, "real_path"))
+	{
+	  return pygmenu_tree_item_get_real_path ((PyObject *) self, NULL);
+	}
       else if (!strcmp (attr, "name"))
 	{
 	  return pygmenu_tree_entry_get_name ((PyObject *) self, NULL);
@@ -1152,6 +1216,7 @@ pygmenu_tree_header_getattro (PyGMenuTreeHeader *self,
 	  return Py_BuildValue ("[sss]",
 				"type",
 				"parent",
+				"real_path",
 				"directory");
 	}
       else if (!strcmp (attr, "type"))
@@ -1162,6 +1227,10 @@ pygmenu_tree_header_getattro (PyGMenuTreeHeader *self,
 	{
 	  return pygmenu_tree_item_get_parent ((PyObject *) self, NULL);
 	}
+      else if (!strcmp (attr, "real_path"))
+	{
+	  return pygmenu_tree_item_get_real_path ((PyObject *) self, NULL);
+	}
       else if (!strcmp (attr, "directory"))
 	{
 	  return pygmenu_tree_header_get_directory ((PyObject *) self, NULL);
@@ -1333,6 +1402,7 @@ pygmenu_tree_alias_getattro (PyGMenuTreeAlias *self,
 	  return Py_BuildValue ("[ssss]",
 				"type",
 				"parent",
+				"real_path",
 				"directory",
 				"item");
 	}
@@ -1344,6 +1414,10 @@ pygmenu_tree_alias_getattro (PyGMenuTreeAlias *self,
 	{
 	  return pygmenu_tree_item_get_parent ((PyObject *) self, NULL);
 	}
+      else if (!strcmp (attr, "real_path"))
+	{
+	  return pygmenu_tree_item_get_real_path ((PyObject *) self, NULL);
+	}
       else if (!strcmp (attr, "directory"))
 	{
 	  return pygmenu_tree_alias_get_directory ((PyObject *) self, NULL);
