Retrieve the descendants of a specific part in a list of dicts and populate the :func:`Part.children()` method.

        Each `Part` has a :func:`Part.children()` method to retrieve the children on the go. This function
        prepopulates the children and the children's children with its children in one call, making the traversal
        through the parttree blazingly fast.

        .. versionadded:: 2.1

        :param batch: Number of Parts to be retrieved in a batch
        :type batch: int (defaults to 200)
        :returns: list of `Parts` with `children`
        :raises APIError: if you cannot create the children tree.

        Example
        -------
        >>> bike = client.part('Bike')
        >>> bike.populate_descendants(batch=150)

def populate_descendants(self, batch=200):
        """
        Retrieve the descendants of a specific part in a list of dicts and populate the :func:`Part.children()` method.

        Each `Part` has a :func:`Part.children()` method to retrieve the children on the go. This function
        prepopulates the children and the children's children with its children in one call, making the traversal
        through the parttree blazingly fast.

        .. versionadded:: 2.1

        :param batch: Number of Parts to be retrieved in a batch
        :type batch: int (defaults to 200)
        :returns: list of `Parts` with `children`
        :raises APIError: if you cannot create the children tree.

        Example
        -------
        >>> bike = client.part('Bike')
        >>> bike.populate_descendants(batch=150)

        """
        descendants_flat_list = list(self._client.parts(pk=self.id, category=self.category, descendants='children',
                                                        batch=batch))

        for parent in descendants_flat_list:
            parent._cached_children = list()
            for child in descendants_flat_list:
                if child.parent_id == parent.id:
                    parent._cached_children.append(child)

        self._cached_children = descendants_flat_list[0]._cached_children