CSP solver for tree-shaped CSPs