public SubMenuItem findParent ( MenuItem toFind ) { synchronized ( subMenuItems ) { SubMenuItem parent = MenuTree . ROOT ; for ( Map . Entry < MenuItem , ArrayList < MenuItem > > entry : subMenuItems . entrySet ( ) ) { for ( MenuItem item : entry . getValue ( ) ) { if ( item . getId ( ) == toFind . getId ( ) ) { parent = asSubMenu ( entry . getKey ( ) ) ; } } } return parent ; } }
Finds the submenu that the provided object belongs to .