Problems that are NP but polynomial on graphs of bounded treewidth
There are probably thousands of examples; there's a short list at ISGCI; the Wikipedia article has plenty of links. Search for "bounded treewidth" and "parameterized complexity treewidth" for many, many more.

Essentially, the problems become easy on graphs of bounded treewidth because:


Although it's NP-complete to determine if a graph has treewidth at most&nbsp;$k$ [1], there is, for every&nbsp;$k$ a linear-time algorithm to compute a tree decomposition of any graph that does actually have treewidth&nbsp;$k$ [2].
Once you have the tree decomposition, you can solve many problems by dynamic programming.


A simple example, which doesn't even use dynamic programming, is the Clique problem. Any clique of a graph must be contained completely in some node of the tree decomposition. That means that a graph of treewidth&nbsp;$k$ can have no clique of size greater than $k+1$ and, to find a clique of size at most $k+1$, you just have to see if each node of the decomposition contains the clique you're looking for. That can be done in linear time if&nbsp;$k$ is a fixed constant, since you're just checking for cliques in $O(n)$ graphs that each have at most $k+1$ vertices.

For a more complicated example, suppose you want to know if a graph&nbsp;$G$ of treewidth&nbsp;4 is 3-colourable. First, compute the tree decomposition. Each vertex of the tree corresponds to a subgraph of at most 5&nbsp;vertices of&nbsp;$G$. For each leaf of the tree, compute by brute force all 3-colourings of the corresponding subgraphs. This is in polynomial time because there are at most&nbsp;$n$ leaves, each corresponds to a subgraph with at most 5&nbsp;vertices and there are at most $3^5=243$ 3-colourings of any such subgraph. Now, for each vertex&nbsp;$v$ of the tree that's adjacent to a leaf, enumerate all the 3-colourings that are compatible with possible colourings of the leaves adjacent to&nbsp;$v$.  (That is, the 3-colourings of the subgraph corresponding to&nbsp;$v$ that can be extended to a 3-colouring of the graph corresponding to&nbsp;$v$ and all its adjacent leaves.) At this point, you can forget about the colourings of the leaves, since everything you need to know about them is now encoded in the distance-1 vertices. Now, iterate up the tree.  You can imagine doing something similar for Hamiltonian path, constructing a path through the whole tree by joining up paths in the subtrees; that's more complicated.



[1] Arnborg, Corneil, and Proskurowski, "Complexity of finding embeddings in a k-tree"., SIAM Journal on Matrix Analysis and Applications 8(2): 277–284, 1987. DOI.

[2] Bodlaender, "A linear time algorithm for finding tree-decompositions of small treewidth", SIAM Journal on Computing 25 (6): 1305–1317, 1996. DOI.