protected function refreshDnIfNeeded(LdapOperationInterface $operation, LdapObject $ldapObject)
    {
        foreach ($operation->getPreOperations() as $childOp) {
            $this->refreshDnIfNeeded($childOp, $ldapObject);
        }

        if ($operation instanceof RenameOperation) {
            $ldapObject->refresh(['dn' => $this->getNewDnFromOperation($operation, $ldapObject)]);
        }

        foreach ($operation->getPostOperations() as $childOp) {
            $this->refreshDnIfNeeded($childOp, $ldapObject);
        }
    }