take into consideration only the previous element as a rect parent, otherwise any other rect will be considered as parent, leading to the blocked save if you do not have any rect in the diagram, or to a wrong width, which does not correspond to the current element.