'Apply the step to a list of nodes. Return the list of nodes for the
next step.'

def apply(self, nodes):

    if (self.step == '.'):
        return nodes
    elif (self.step == '..'):
        return [node.parent for node in nodes]
    result = []
    for node in nodes:
        if (self.axis == AXIS_CHILD):
            found = node.findAll(recursive=False, **self.soup_args)
        elif (self.axis == AXIS_DESCENDANT):
            found = node.findAll(recursive=True, **self.soup_args)
        elif (self.axis == AXIS_ATTRIBUTE):
            try:
                found = [node[self.node_test]]
            except KeyError:
                found = []
        elif (self.axis == AXIS_FOLLOWING_SIBLING):
            found = node.findNextSiblings(**self.soup_args)
        elif (self.axis == AXIS_PRECEDING_SIBLING):
            found = node.findPreviousSiblings(**self.soup_args)
        elif (self.axis == AXIS_FOLLOWING):
            last = node
            while ((not isinstance(last, BeautifulSoup.NavigableString)) and (len(last.contents) > 0)):
                last = last.contents[(-1)]
            found = last.findAllNext(**self.soup_args)
        elif (self.axis == AXIS_ANCESTOR):
            found = node.findParents(**self.soup_args)
        if (self.index is not None):
            if found:
                if (len(found) > self.index):
                    found = [found[self.index]]
                else:
                    found = []
        if found:
            for checker in self.checkers:
                found = filter(checker, found)
            result.extend(found)
    return result
