private function getInstancesToMove(array $classes = [], array $instances = [], array &$statuses = [])
    {
        $movableInstances = [];

        // Check if a class belong to class to move
        /** @var core_kernel_classes_Resource|core_kernel_classes_Class $instance */
        foreach ($instances as $instance) {
            $isValid = true;
            foreach ($classes as $class) {
                if ($instance instanceof core_kernel_classes_Class) {
                    //Disallow moving a class to $class. True only for classes which are already subclasses of $class
                    if ($class->getUri() != $instance->getUri() && $instance->isSubClassOf($class)) {
                        $statuses[$instance->getUri()] = [
                            'success' => false,
                            'message' => sprintf('Instance "%s" cannot be moved to class to move "%s"', $instance->getUri(), $class->getUri()),
                        ];
                        $isValid = false;
                        break;
                    }
                } else {
                    //Disallow moving instances to $class. True only for instances which already belongs to $class
                    if ($instance->isInstanceOf($class)) {
                        $statuses[$instance->getUri()] = [
                            'success' => false,
                            'message' => sprintf('Instance "%s" cannot be moved to class to move "%s"', $instance->getUri(), $class->getUri()),
                        ];
                        $isValid = false;
                        break;
                    }
                }
            }
            if ($isValid) {
                $movableInstances[$instance->getUri()] = $instance;
            }
        }

        return $movableInstances;
    }