refactoring python hierarchy