public Optional < MenuItem > getMenuById ( SubMenuItem root , int id ) { return getMenuItems ( root ) . stream ( ) . filter ( item -> item . getId ( ) == id ) . findFirst ( ) ; }
Gets the menu item with the specified ID in a given submenu . If you don t know the sub menu call the findMenuItem to obtain the parent .