Fixes #5522. Only adding children elements to menu items if they haven't already been added.