'Apply the path to a node. Return the resulting list of nodes.
Apply the steps in the path sequentially by sending the output of each
step as input to the next step.'

def apply(self, node):

    if (self.path[0] == '/'):
        if ((not isinstance(node, BeautifulSoup.Tag)) or (node.name != '[document]')):
            node = node.findParent('[document]')
    nodes = [node]
    for step in self.steps:
        nodes = step.apply(nodes)
    return nodes
