<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_unnecessary_segments(query):
 """Filter segments are not needed on CVX"""

    segment_model = segment_models.NetworkSegment
    network_model = models_v2.Network
    query = (query
             .join_if_necessary(network_model)
             .join_if_necessary(segment_model)
             .filter(network_model.project_id != '')
             .filter_network_type())
    return query