completed import_hierarchy function