<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _construct_as_path_attr(self, as_path_attr, as4_path_attr):
 """Marge AS_PATH and AS4_PATH attribute instances into a single AS_PATH instance."""


        def _listify(li):
            """Reconstruct AS_PATH list.

            Example::

                >>> _listify([[1, 2, 3], {4, 5}, [6, 7]])
                [1, 2, 3, {4, 5}, 6, 7]
            """
            lo = []
            for l in li:
                if isinstance(l, list):
                    lo.extend(l)
                elif isinstance(l, set):
                    lo.append(l)
                else:
                    pass
            return lo

        # If AS4_PATH attribute is None, returns the given AS_PATH attribute
        if as4_path_attr is None:
            return as_path_attr

        # If AS_PATH is shorter than AS4_PATH, AS4_PATH should be ignored.
        if as_path_attr.get_as_path_len() < as4_path_attr.get_as_path_len():
            return as_path_attr

        org_as_path_list = _listify(as_path_attr.path_seg_list)
        as4_path_list = _listify(as4_path_attr.path_seg_list)

        # Reverse to compare backward.
        org_as_path_list.reverse()
        as4_path_list.reverse()

        new_as_path_list = []
        tmp_list = []
        for as_path, as4_path in zip_longest(org_as_path_list, as4_path_list):
            if as4_path is None:
                if isinstance(as_path, int):
                    tmp_list.insert(0, as_path)
                elif isinstance(as_path, set):
                    if tmp_list:
                        new_as_path_list.insert(0, tmp_list)
                        tmp_list = []
                    new_as_path_list.insert(0, as_path)
                else:
                    pass
            elif isinstance(as4_path, int):
                tmp_list.insert(0, as4_path)
            elif isinstance(as4_path, set):
                if tmp_list:
                    new_as_path_list.insert(0, tmp_list)
                    tmp_list = []
                new_as_path_list.insert(0, as4_path)
            else:
                pass
        if tmp_list:
            new_as_path_list.insert(0, tmp_list)

        return bgp.BGPPathAttributeAsPath(new_as_path_list)