<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_structure(element, reference=None):
 """ Get the element structure :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference>` or from a message profile :return: a dictionary containing the structure data """

        if reference is None:
            try:
                reference = load_reference(element.name, element.classname, element.version)
            except (ChildNotFound, KeyError):
                raise InvalidName(element.classname, element.name)
        if not isinstance(reference, collections.Sequence):
            raise Exception
        return ElementFinder._parse_structure(element, reference)