def element_to_objects(<EOL>element: etree.ElementTree, sender: str, sender_key_fetcher:Callable[[str], str]=None, user: UserType =None,<EOL>) -> List:
entities = []<EOL>cls = MAPPINGS.get(element.tag)<EOL>if not cls:<EOL><INDENT>return []<EOL><DEDENT>attrs = xml_children_as_dict(element)<EOL>transformed = transform_attributes(attrs, cls)<EOL>if hasattr(cls, "<STR_LIT>"):<EOL><INDENT>transformed = cls.fill_extra_attributes(transformed)<EOL><DEDENT>entity = cls(**transformed)<EOL>entity._source_protocol = "<STR_LIT>"<EOL>entity._source_object = etree.tostring(element)<EOL>if user:<EOL><INDENT>entity._receiving_actor_id = user.id<EOL><DEDENT>if issubclass(cls, DiasporaRelayableMixin):<EOL><INDENT>entity._xml_tags = get_element_child_info(element, "<STR_LIT>")<EOL>if sender_key_fetcher:<EOL><INDENT>entity._sender_key = sender_key_fetcher(entity.actor_id)<EOL><DEDENT>else:<EOL><INDENT>profile = retrieve_and_parse_profile(entity.handle)<EOL>if profile:<EOL><INDENT>entity._sender_key = profile.public_key<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if not check_sender_and_entity_handle_match(sender, entity.handle):<EOL><INDENT>return []<EOL><DEDENT><DEDENT>try:<EOL><INDENT>entity.validate()<EOL><DEDENT>except ValueError as ex:<EOL><INDENT>logger.error("<STR_LIT>", entity, ex, extra={<EOL>"<STR_LIT>": attrs,<EOL>"<STR_LIT>": transformed,<EOL>})<EOL>return []<EOL><DEDENT>entity._mentions = entity.extract_mentions()<EOL>for child in element:<EOL><INDENT>entity._children.extend(element_to_objects(child, sender, user=user))<EOL><DEDENT>entities.append(entity)<EOL>return entities<EOL>
Transform an Element to a list of entities recursively.

    Possible child entities are added to each entity ``_children`` list.

    :param tree: Element
    :param sender: Payload sender id
    :param sender_key_fetcher: Function to fetch sender public key. If not given, key will always be fetched
        over network. The function should take sender handle as the only parameter.
    :param user: Optional receiving user object. If given, should have an ``id``.
    :returns: list of entities