What exactly is your aim here? Are you looking to create a tree from a contour, or compute the contour of a tree?
If the latter, this contour is known as the medial axis of a shape. One way to think about finding this is place the largest circles possible (at different points) within the shape such that the circles are flush with at least 2 edges, and then join up circle centers. Fortunately, computing a Delaunay triangulation of the shape’s vertices will provide the circles (which are found by computing the circumcircle of each resulting triangle).
Processing Geometry Suite provides a method to find the medial axis of a PShape (and supports medial axis pruning to reject small/noisy segments, as seen below).