# Path: pdfminer/settings.py
# STRICT = False
# 
# Path: pdfminer/pdfparser.py
# class PDFSyntaxError(PDFException):
#     pass
# 
# Path: pdfminer/pdftypes.py
# def list_value(x: object) -> Union[List[Any], Tuple[Any, ...]]:
#     x = resolve1(x)
#     if not isinstance(x, (list, tuple)):
#         if settings.STRICT:
#             raise PDFTypeError("List required: %r" % x)
#         return []
#     return x
# 
# def int_value(x: object) -> int:
#     x = resolve1(x)
#     if not isinstance(x, int):
#         if settings.STRICT:
#             raise PDFTypeError("Integer required: %r" % x)
#         return 0
#     return x
# 
# def dict_value(x: object) -> Dict[Any, Any]:
#     x = resolve1(x)
#     if not isinstance(x, dict):
#         if settings.STRICT:
#             logger.error("PDFTypeError : Dict required: %r", x)
#             raise PDFTypeError("Dict required: %r" % x)
#         return {}
#     return x
# 
# Path: pdfminer/utils.py
# def choplist(n: int, seq: Iterable[_T]) -> Iterator[Tuple[_T, ...]]:
#     """Groups every n elements of the list."""
#     r = []
#     for x in seq:
#         r.append(x)
#         if len(r) == n:
#             yield tuple(r)
#             r = []
#     return


from typing import Any, Iterable, List, Optional, Tuple
from pdfminer import settings
from pdfminer.pdfparser import PDFSyntaxError
from pdfminer.pdftypes import list_value, int_value, dict_value
from pdfminer.utils import choplist



class NumberTree:
    """A PDF number tree.

    See Section 3.8.6 of the PDF Reference.
    """

    def __init__(self, obj: Any):
        self._obj = dict_value(obj)
        self.nums: Optional[Iterable[Any]] = None
        self.kids: Optional[Iterable[Any]] = None
        self.limits: Optional[Iterable[Any]] = None

        if "Nums" in self._obj:
            self.nums = list_value(self._obj["Nums"])
        if "Kids" in self._obj:
            self.kids = list_value(self._obj["Kids"])
        if "Limits" in self._obj:
            self.limits = list_value(self._obj["Limits"])

    def _parse(self) -> List[Tuple[int, Any]]:
        items = []
        if self.nums:  # Leaf node

# Path: pdfminer/settings.py
# STRICT = False
# 
# Path: pdfminer/pdfparser.py
# class PDFSyntaxError(PDFException):
#     pass
# 
# Path: pdfminer/pdftypes.py
# def list_value(x: object) -> Union[List[Any], Tuple[Any, ...]]:
#     x = resolve1(x)
#     if not isinstance(x, (list, tuple)):
#         if settings.STRICT:
#             raise PDFTypeError("List required: %r" % x)
#         return []
#     return x
# 
# def int_value(x: object) -> int:
#     x = resolve1(x)
#     if not isinstance(x, int):
#         if settings.STRICT:
#             raise PDFTypeError("Integer required: %r" % x)
#         return 0
#     return x
# 
# def dict_value(x: object) -> Dict[Any, Any]:
#     x = resolve1(x)
#     if not isinstance(x, dict):
#         if settings.STRICT:
#             logger.error("PDFTypeError : Dict required: %r", x)
#             raise PDFTypeError("Dict required: %r" % x)
#         return {}
#     return x
# 
# Path: pdfminer/utils.py
# def choplist(n: int, seq: Iterable[_T]) -> Iterator[Tuple[_T, ...]]:
#     """Groups every n elements of the list."""
#     r = []
#     for x in seq:
#         r.append(x)
#         if len(r) == n:
#             yield tuple(r)
#             r = []
#     return


# Path: pdfminer/data_structures.py
from typing import Any, Iterable, List, Optional, Tuple
from pdfminer import settings
from pdfminer.pdfparser import PDFSyntaxError
from pdfminer.pdftypes import list_value, int_value, dict_value
from pdfminer.utils import choplist




class NumberTree:
    """A PDF number tree.

    See Section 3.8.6 of the PDF Reference.
    """

    def __init__(self, obj: Any):
        self._obj = dict_value(obj)
        self.nums: Optional[Iterable[Any]] = None
        self.kids: Optional[Iterable[Any]] = None
        self.limits: Optional[Iterable[Any]] = None

        if "Nums" in self._obj:
            self.nums = list_value(self._obj["Nums"])
        if "Kids" in self._obj:
            self.kids = list_value(self._obj["Kids"])
        if "Limits" in self._obj:
            self.limits = list_value(self._obj["Limits"])

    def _parse(self) -> List[Tuple[int, Any]]:
        items = []
        if self.nums:  # Leaf node

            for k, v in choplist(2, self.nums):