def get_axdr_length(data: bytearray):
    """
    Will find the length of an xadr element assuming the length is the first bytes in
    the data
    Works with bytearray and will remove element from the array as it finds the
    variable length.
    """
    length_data = bytearray()
    first_byte = data.pop(0)
    length_is_multiple_bytes = bool(first_byte & 0b10000000)
    if not length_is_multiple_bytes:
        return first_byte
    number_of_bytes_representing_the_length = first_byte & 0b01111111
    for _ in range(0, number_of_bytes_representing_the_length):
        length_data.append(data.pop(0))
    return int.from_bytes(length_data, "big")