---
title: "Access the ancestors of an item"
slug: "access-the-ancestors-of-an-item"
abstract: "How to access the ancestors of an item using the Sitecore.Data.Items.Item.Parent property."
---
# Access the ancestors of an item

You can use the `Sitecore.Data.Items.Item.Parent` property in a recursive method to access the ancestors of an item. For example, to access the ancestors of the */Sitecore/Content/Home* item in the *Master* database:

```csharp
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");

Sitecore.Data.Items.Item home = master.GetItem("/sitecore/content/home");

ProcessRecursively(home.Parent);

...

private void ProcessRecursively(Sitecore.Data.Items.Item item)
{
    if (item.Parent != null )
    {
        // Process parent item
        ProcessRecursively(item.Parent);
    }
}

```

> [!warning]
> If the recursive method passes its argument to itself, then that method enters an infinite loop.