I think this line and the line below are independent of this "if is a stackserviceaction type", and could be done always that the parent is not null.