using last occurrence of parent in children