public function parents($selector = null)
{
$stack = array();
if (!$this->elements) {
$this->debug('parents() - stack empty');
}
foreach ($this->elements as $node) {
$test = $node;
while ($test->parentNode) {
$test = $test->parentNode;
if ($this->isRoot($test)) {
break;
}
if (!$this->elementsContainsNode($test, $stack)) {
$stack[] = $test;
continue;
}
}
}
$this->elementsBackup = $this->elements;
$this->elements = $stack;
if ($selector) {
$this->filter($selector, true);
}
return $this->newInstance();
}