src/Labi/Database/Utility/Condition.php
private function cloneBrackets($brackets)
    {
        // tworze klon nawiasow
        $cloned = new \stdClass();
        $cloned->type = $brackets->type;
        $cloned->operator = $brackets->operator;
        $cloned->elements = array();

        foreach ($brackets->elements as $element) {
            if ($element->type === 'brackets') {
                // kolunuje nawiasy
                array_push($cloned->elements, $this->cloneBrackets($element));
            }else{
                // wrzucam elementy do listy
                array_push($cloned->elements, $element);
            }
        }

        return $cloned;
    }
private function cloneBrackets($brackets)
    {
        // tworze klon nawiasow
        $cloned = new \stdClass();
        $cloned->type = $brackets->type;
        $cloned->operator = $brackets->operator;
        $cloned->elements = array();

        foreach ($brackets->elements as $element) {
            if ($element->type === 'brackets') {
                // kolunuje nawiasy
                array_push($cloned->elements, $this->cloneBrackets($element));
            }else{
                // wrzucam elementy do listy
                array_push($cloned->elements, $element);
            }
        }

        return $cloned;
    }
- magic