CSP duality and trees of bounded pathwidth