'Parse each config in self.proprietary_tool_confs (the default is tool_conf.xml) and generate a list of Elements that are
either ToolSection elements or Tool elements.  These will be used to generate new entries in the migrated_tools_conf.xml
file for the installed tools.'

def get_proprietary_tool_panel_elems(self, latest_tool_migration_script_number):

    tools_xml_file_path = os.path.abspath(os.path.join('scripts', 'migrate_tools', ('%04d_tools.xml' % latest_tool_migration_script_number)))
    migrated_tool_configs = []
    (tree, error_message) = xml_util.parse_xml(tools_xml_file_path)
    if (tree is None):
        return []
    root = tree.getroot()
    for elem in root:
        if (elem.tag == 'repository'):
            for tool_elem in elem:
                migrated_tool_configs.append(tool_elem.get('file'))
    tool_panel_elems = []
    for proprietary_tool_conf in self.proprietary_tool_confs:
        (tree, error_message) = xml_util.parse_xml(proprietary_tool_conf)
        if (tree is None):
            return []
        root = tree.getroot()
        for elem in root:
            if (elem.tag == 'tool'):
                file_path = elem.get('file', None)
                if file_path:
                    if (file_path in migrated_tool_configs):
                        if (elem not in tool_panel_elems):
                            tool_panel_elems.append(elem)
            elif (elem.tag == 'section'):
                for section_elem in elem:
                    if (section_elem.tag == 'tool'):
                        file_path = section_elem.get('file', None)
                        if file_path:
                            if (file_path in migrated_tool_configs):
                                if (elem not in tool_panel_elems):
                                    tool_panel_elems.append(elem)
    return tool_panel_elems
