def get_z_variable(nc):
    """
    Returns the name of the variable that defines the Z axis or height/depth

    :param netCDF4.Dataset nc: netCDF dataset
    """
    axis_z = nc.get_variables_by_attributes(axis='Z')
    if axis_z:
        return axis_z[0].name
    valid_standard_names = 'depth', 'height', 'altitude'
    z = nc.get_variables_by_attributes(standard_name=lambda x: x in
        valid_standard_names)
    if z:
        return z[0].name
    return
