<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prepare_instance_properties(self, properties, factory_properties):
 # type: (dict, dict) -> dict """ Prepares the properties of a component instance, based on its configuration, factory and framework properties :param properties: Component instance properties :param factory_properties: Component factory "default" properties :return: The merged properties """

        # Normalize given properties
        if properties is None or not isinstance(properties, dict):
            properties = {}

        # Use framework properties to fill missing ones
        framework = self.__context.get_framework()
        for property_name in factory_properties:
            if property_name not in properties:
                # Missing property
                value = framework.get_property(property_name)
                if value is not None:
                    # Set the property value
                    properties[property_name] = value

        return properties