def stepAxis(self, op, p, sourceSequence):
        targetSequence = []
        for node in sourceSequence:
            if not isinstance(node,(ModelObject, etree._ElementTree, ModelAttribute)):
                raise XPathException(self.progHeader, 'err:XPTY0020', _('Axis step {0} context item is not a node: {1}').format(op, node))
            targetNodes = []
            if isinstance(p,QNameDef):
                ns = p.namespaceURI; localname = p.localName; axis = p.axis
                if p.isAttribute:
                    if isinstance(node,ModelObject):
                        attrTag = p.localName if p.unprefixed else p.clarkNotation
                        modelAttribute = None
                        try:
                            modelAttribute = node.xAttributes[attrTag]
                        except (AttributeError, TypeError, IndexError, KeyError):
                            # may be lax or deferred validated
                            try:
                                xmlValidate(node.modelXbrl, node, p)
                                modelAttribute = node.xAttributes[attrTag]
                            except (AttributeError, __HOLE__, IndexError, KeyError):
                                pass
                        if modelAttribute is None:
                            value = node.get(attrTag)
                            if value is not None:
                                targetNodes.append(ModelAttribute(node,p.clarkNotation,UNKNOWN,value,value,value))
                        elif modelAttribute.xValid >= VALID:
                                targetNodes.append(modelAttribute)
                elif op == '/' or op is None:
                    if axis is None or axis == "child":
                        if isinstance(node,(ModelObject, etree._ElementTree)):
                            targetNodes = XmlUtil.children(node, ns, localname)
                    elif axis == "parent":
                        if isinstance(node,ModelAttribute):
                            parentNode = [ node.modelElement ]
                        else:
                            parentNode = [ XmlUtil.parent(node) ]
                        if (isinstance(node,ModelObject) and
                                (not ns or ns == parentNode.namespaceURI or ns == "*") and
                            (localname == parentNode.localName or localname == "*")):
                            targetNodes = [ parentNode ]
                    elif axis == "self":
                        if (isinstance(node,ModelObject) and
                                (not ns or ns == node.namespaceURI or ns == "*") and
                            (localname == node.localName or localname == "*")):
                            targetNodes = [ node ]
                    elif axis.startswith("descendant"):
                        if isinstance(node,(ModelObject, etree._ElementTree)):
                            targetNodes = XmlUtil.descendants(node, ns, localname)
                            if (axis.endswith("-or-self") and
                                isinstance(node,ModelObject) and
                                (not ns or ns == node.namespaceURI or ns == "*") and
                                (localname == node.localName or localname == "*")):
                                targetNodes.append(node) 
                    elif axis.startswith("ancestor"):
                        if isinstance(node,ModelObject):
                            targetNodes = [ancestor
                                           for ancestor in XmlUtil.ancestors(node)
                                           if ((not ns or ns == ancestor.namespaceURI or ns == "*") and
                                               (localname == ancestor.localName or localname == "*"))]
                            if (axis.endswith("-or-self") and
                                isinstance(node,ModelObject) and
                                (not ns or ns == node.namespaceURI or ns == "*") and
                                (localname == node.localName or localname == "*")):
                                targetNodes.insert(0, node) 
                    elif axis.endswith("-sibling"):
                        if isinstance(node,ModelObject):
                            targetNodes = [sibling
                                           for sibling in node.itersiblings(preceding=axis.startswith("preceding"))
                                           if ((not ns or ns == sibling.namespaceURI or ns == "*") and
                                               (localname == sibling.localName or localname == "*"))]
                    elif axis == "preceding":
                        if isinstance(node,ModelObject):
                            for preceding in node.getroottree().iter():
                                if preceding == node:
                                    break
                                elif ((not ns or ns == preceding.namespaceURI or ns == "*") and
                                      (localname == preceding.localName or localname == "*")):
                                    targetNodes.append(preceding)
                    elif axis == "following":
                        if isinstance(node,ModelObject):
                            foundNode = False
                            for following in node.getroottree().iter():
                                if following == node:
                                    foundNode = True
                                elif (foundNode and
                                      (not ns or ns == following.namespaceURI or ns == "*") and
                                      (localname == following.localName or localname == "*")):
                                    targetNodes.append(following)
                elif op == '//':
                    if isinstance(node,(ModelObject, etree. _ElementTree)):
                        targetNodes = XmlUtil.descendants(node, ns, localname)
                elif op == '..':
                    if isinstance(node,ModelAttribute):
                        targetNodes = [ node.modelElement ]
                    else:
                        targetNodes = [ XmlUtil.parent(node) ]
            elif isinstance(p, OperationDef) and isinstance(p.name,QNameDef):
                if isinstance(node,ModelObject):
                    if p.name.localName == "text": # note this is not string value, just child text
                        targetNodes = [node.textValue]
                    # todo: add element, attribute, node, etc...
            elif p == '*':  # wildcard
                if op == '/' or op is None:
                    if isinstance(node,(ModelObject, etree._ElementTree)):
                        targetNodes = XmlUtil.children(node, '*', '*')
                elif op == '//':
                    if isinstance(node,(ModelObject, etree._ElementTree)):
                        targetNodes = XmlUtil.descendants(node, '*', '*')
            targetSequence.extend(targetNodes)
        return targetSequence
dataset/ETHPy150Open Arelle/Arelle/arelle/XPathContext.py/XPathContext.stepAxis