Query support

I want to write a tql to find out something like this.

VM1 (Child) is moving from Server A to Server B. we are not able to use the vmotion job and currently we have a ticket with HP to rectify the issue. Now as a workaround daily we are deleting the entire vm to esx relationship and rediscover it. But sometimes the job fails. if we stop this deletion job we get multiple relationship for a vm (a child has 2 parent relation)

so we were not able to get the correct relationships.

Is it possible to find the latest relationship and keep that and delete the old one? 

I want to see VM1 relationship to Server A and Server B now. and delete the server A relation and retain the server B relationship.