/**
  * 在一个集合中查找子
  *
  * @param menuList 所有菜单集合
  * @param parentid 父id
  * @return 找到的子集合
  */
 private List<Menu> getChildren(List<Menu> menuList, Integer parentid) {
   List<Menu> children = new ArrayList<Menu>();
   for (Menu menu : menuList) {
     if (menu.getPid().compareTo(parentid) == 0) {
       menu.setChildren(this.getChildren(menuList, menu.getId()));
       children.add(menu);
     }
   }
   return children;
 }
 @Override
 public List<Menu> getMenuTree(Integer menuid) {
   if (menuid == null) throw new IllegalArgumentException("menuid argument is null");
   List<Menu> menuList = this.getMenuList();
   List<Menu> topMenuList = new ArrayList<Menu>();
   for (Menu menu : menuList) {
     if (menu.getPid().compareTo(menuid) == 0) {
       List<Menu> children = this.getChildren(menuList, menu.getId());
       menu.setChildren(children);
       topMenuList.add(menu);
     }
   }
   return topMenuList;
 }