def get_field(DataModelClass, field_name):
    """ Returns a SQLAlchemy Field from a field name such as 'name' or 'parent.name'.
        Returns None if no field exists by that field name.
    """
    # Handle hierarchical field names such as 'parent.name'
    if '.' in field_name:
        relationship_name, field_name = field_name.split('.', 1)
        relationship = getattr(DataModelClass, relationship_name)
        return get_field(relationship.property.mapper.entity, field_name)

    # Handle flat field names such as 'name'
    return getattr(DataModelClass, field_name, None)