added code to detect parent when creating version