public static function compareIterators(\Iterator $lhs, \Iterator $rhs, $identical = false)
    {
        if ($lhs instanceof \RecursiveIterator) {
            if ($rhs instanceof \RecursiveIterator) {
                $it = new RecursiveDualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0);
                $it = new RecursiveCompareDualIterator($it);
            } else {
                return false;
            }
        } else {
            $it = new DualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0);
        }

        if ($identical) {
            foreach ($it as $n) {
                if (!$it->areIdentical()) {
                    return false;
                }
            }
        } else {
            foreach ($it as $n) {
                if (!$it->areEqual()) {
                    return false;
                }
            }
        }

        return $identical ? $it->areIdentical() : $it->areEqual();
    }