Make get_parent more generic