Since this table should be updated after a data import, so after a massive upsert, ideally I would i'd like to have a function
called after that is completed, in order to (re)build the 'path' column for each record, which means rebuild the tree.
Have you considered/tried an "FOR EACH STATEMENT" trigger instead of "FOR EACH ROW"?
The transition tables feature introduced in v10 probably will be of significant help here as well - though I haven't any practical experience with it personally.