write getMenuAncestors funtion