def get_vector(vector, vulnerability):
    """Get a vector out of the CVSS definition (if present) for a vulnerability."""
    vectors = []

    # Some sources have metadata as { metadata: NVD: CVSSv3: Vectors: "..." }
    # and others have { metadata: CVSSv2: "..." }
    if 'metadata' in vulnerability:
        if 'NVD' in vulnerability['metadata']:
            vectors = vulnerability['metadata']['NVD'].get(
                'CVSSv3', {}).get('Vectors', '').split('/')
            if len(vectors) == 1:
                vectors = vulnerability['metadata']['NVD'].get(
                    'CVSSv2', {}).get('Vectors', '').split('/')
        else:
            cvssV2 = vulnerability['metadata'].get('CVSSv2', None)
            if isinstance(cvssV2, str):
                vectors = cvssV2.split('/')
                # The first element is the score, which we're not using here
                vectors.pop(0)

    found = list(filter(lambda x: vector in x, vectors))
    if found:
        return found[0]
    return None