public function get_reply_count_for_post_id_in_discussion_id(
            stdClass $user, int $postid, int $discussionid, bool $canseeprivatereplies) : int {
        [
            'where' => $privatewhere,
            'params' => $privateparams,
        ] = $this->get_private_reply_sql($user, $canseeprivatereplies);

        $alias = $this->get_table_alias();
        $table = self::TABLE;

        $sql = "SELECT {$alias}.id, {$alias}.parent
                  FROM {{$table}} {$alias}
                 WHERE p.discussion = :discussionid {$privatewhere}";

        $postparents = $this->get_db()->get_records_sql_menu($sql, array_merge([
                'discussionid' => $discussionid,
            ], $privateparams));

        return $this->count_children_from_parent_recursively($postparents, $postid);
    }