'Parse an if construct.'

def parse_if(self):

    node = result = nodes.If(lineno=self.stream.expect('name:if').lineno)
    while 1:
        node.test = self.parse_tuple(with_condexpr=False)
        node.body = self.parse_statements(('name:elif', 'name:else', 'name:endif'))
        token = next(self.stream)
        if token.test('name:elif'):
            new_node = nodes.If(lineno=self.stream.current.lineno)
            node.else_ = [new_node]
            node = new_node
            continue
        elif token.test('name:else'):
            node.else_ = self.parse_statements(('name:endif',), drop_needle=True)
        else:
            node.else_ = []
        break
    return result
