# Source URL: https://dev.epicgames.com/community/learning/tutorials/o9vG/fortnite-item_component-agent
# Local doc: verse-cortex-epic-docs/community/learning/tutorials/o9vG/fortnite-item_component-agent.md
(Entity:entity).GetRootAgent<public>()<decides><transacts>:agent=
if(Agent := agent[Entity]):
Agent
else:
Entity.GetParent[].GetRootAgent[]
Verse Libraryverse
01 Snippet
Recursively traverses the scene graph parent hierarchy of an entity to find and return its root agent.
extracted-snippets/community/learning/tutorials/o9vG/fortnite-item_component-agent/01-snippet.verse