Hierarchy extraction