I think that this method can be combined with the method above; in fact this one includes the method above:
* the logic at the end, should happen only if parentActionId == null; i.e. root. This way, the 2 methods become 1