<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lines_required(self, tree, count=0):
 """Calculate number of lines required to draw ``tree``"""

        if all([
            isinstance(tree, dict),
            type(tree) != BarDescriptor
        ]):
            return sum(self.lines_required(v, count=count)
                       for v in tree.values()) + 2
        elif isinstance(tree, BarDescriptor):
            if tree.get("kwargs", {}).get("title_pos") in ["left", "right"]:
                return 1
            else:
                return 2