Stay closer to regular pickle protocol

Pickle by default pickles obj.__dict__, __getstate__ overrules that.
Rather than returning something completely incompatible with __dict__,
return a shallow copy of __dict__ with all contained weak references
removed. This gets rid of the 'parent' attribute in a way compatible to
the default __setstate__ implementation and as such removes the need to
provide a non-default implementation for that.

Additionally move this pickle-protocol behaviour to a mixin-class to
allow easy reuse where necessary.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Allow pickling of `parent` attribute on `STree`s

From the pickle documentation:
> Object sharing happens when there are multiple references to the same
> object in different places in the object hierarchy being serialized.
> pickle stores such objects only once, and ensures that all other
> references point to the master copy.

I.e. the circular parent references *can* be serialized by converting
the weak references to strong references while serializing and
converting back to weak references while deserializing.

This change actually does that. As a result pickling a subtree with
parents computed will actually end up storing the entire tree while upon
deserialization all parents of the subtree's root will end up getting
destroyed immediately.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Merge branch 'pickling'