def _get_linewidth(tree, linewidth, diameter_scale):
if diameter_scale is not None and tree:<EOL><INDENT>linewidth = [<NUM_LIT:2> * segment_radius(s) * diameter_scale<EOL>for s in iter_segments(tree)]<EOL><DEDENT>return linewidth<EOL>
calculate the desired linewidth based on tree contents

    If diameter_scale exists, it is used to scale the diameter of each of the segments
    in the tree
    If diameter_scale is None, the linewidth is used.