private function count_children_from_parent_recursively(array $postparents, int $postid) : int {
        if (!isset($postparents[$postid])) {
            // Post not found at all.
            return 0;
        }

        $count = 0;
        foreach ($postparents as $pid => $parentid) {
            if ($postid == $parentid) {
                $count += $this->count_children_from_parent_recursively($postparents, $pid) + 1;
            }
        }

        return $count;
    }
private function count_children_from_parent_recursively(array $postparents, int $postid) : int {
        if (!isset($postparents[$postid])) {
            // Post not found at all.
            return 0;
        }

        $count = 0;
        foreach ($postparents as $pid => $parentid) {
            if ($postid == $parentid) {
                $count += $this->count_children_from_parent_recursively($postparents, $pid) + 1;
            }
        }

        return $count;
    }
private function count_children_from_parent_recursively ( array $ postparents , int $ postid ) : int { if ( ! isset ( $ postparents [ $ postid ] ) ) { // Post not found at all. return 0 ; } $ count = 0 ; foreach ( $ postparents as $ pid => $ parentid ) { if ( $ postid == $ parentid ) { $ count += $ this -> count_children_from_parent_recursively ( $ postparents , $ pid ) + 1 ; } } return $ count ; }
Count the children whose parent matches the current record recursively.

@param   array   $postparents The full mapping of posts.
@param   int     $postid The ID to check for
@return  int     $count
Count the children whose parent matches the current record recursively .