package{ import flash.display.Sprite; public class Main extends Sprite{ public function Main(){ getRoot(someChild); } public function getRoot (childNode:XML):XML { var parentNode:XML = childNode.parent( ); if (parentNode != null) { return getRoot(parentNode); } else { return childNode; } } } }