"Materialized Path" algorithm implementation in Python/Django, without sorting features - in order to improve performance.