def preload(pytac_lat):
    """Load the elements onto an 'elems' object's attributes by family so that
    groups of elements of the same family can be more easily accessed, e.g.
    'elems.bpm' will return a list of all the BPMs in the lattice. As a
    special case 'elems.all' will return all the elements in the lattice.

    Args:
        pytac_lat (pytac.lattice.Lattice): The Pytac lattice object from which
                                            to get the elements.

    returns:
        obj: The elems object with the elements loaded onto it by family.
    """

    class elems:
        pass

    setattr(elems, "all", pytac_lat.get_elements())
    for family in pytac_lat.get_all_families():
        setattr(elems, family.lower(), pytac_lat.get_elements(family))
    return elems