'Integrating Model, Serializer and Algorithm in a tree structure coherently

I have a tree-like structure of objects, linked to each-other with foreign keys.

Each object's fields are stored in a model. Each object has a serializer. Each object has a few routines, now stored in an algorithm class.

There is a serializer that recreates the tree structure into a nested dictionary.

How do I merge these 3 facets of each object into a single object?

Should I create a child object, which inherits from the three others (scary)? or should I include the model and the serializer inside my algo class as inner objects (seems more modular and independent)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source