class EntityReference implements Serializable, Cloneable, Comparable<EntityReference> {

    public EntityReference extractReference(EntityType type)
    {
        EntityReference reference = this;

        while (reference != null && reference.getType() != type) {
            reference = reference.getParent();
        }

        return reference;
    }

    public  EntityReference(String name, EntityType type);
    public  EntityReference(String name, EntityType type, EntityReference parent);

}