private static function traverse(
        $deep,
        &$object,
        $mapFunction,
        $seen = array()
    ) {
        if ($object instanceof AVObject)
        {
            if (in_array($object, $seen, true))
            {
                return null;
            }
            $seen[] = $object;
            if ($deep)
            {
                self::traverse($deep, $object->estimatedData, $mapFunction, $seen);
            }

            return $mapFunction($object);
        }
        if ($object instanceof AVRelation || $object instanceof AVFile)
        {
            return $mapFunction($object);
        }
        if (is_array($object))
        {
            foreach ($object as $key => $value)
            {
                self::traverse($deep, $value, $mapFunction, $seen);
            }

            return $mapFunction($object);
        }

        return $mapFunction($object);
    }
private static function traverse(
        $deep,
        &$object,
        $mapFunction,
        $seen = array()
    ) {
        if ($object instanceof AVObject)
        {
            if (in_array($object, $seen, true))
            {
                return null;
            }
            $seen[] = $object;
            if ($deep)
            {
                self::traverse($deep, $object->estimatedData, $mapFunction, $seen);
            }

            return $mapFunction($object);
        }
        if ($object instanceof AVRelation || $object instanceof AVFile)
        {
            return $mapFunction($object);
        }
        if (is_array($object))
        {
            foreach ($object as $key => $value)
            {
                self::traverse($deep, $value, $mapFunction, $seen);
            }

            return $mapFunction($object);
        }

        return $mapFunction($object);
    }
private static function traverse ( $ deep , & $ object , $ mapFunction , $ seen = array ( ) ) { if ( $ object instanceof AVObject ) { if ( in_array ( $ object , $ seen , true ) ) { return null ; } $ seen [ ] = $ object ; if ( $ deep ) { self :: traverse ( $ deep , $ object -> estimatedData , $ mapFunction , $ seen ) ; } return $ mapFunction ( $ object ) ; } if ( $ object instanceof AVRelation || $ object instanceof AVFile ) { return $ mapFunction ( $ object ) ; } if ( is_array ( $ object ) ) { foreach ( $ object as $ key => $ value ) { self :: traverse ( $ deep , $ value , $ mapFunction , $ seen ) ; } return $ mapFunction ( $ object ) ; } return $ mapFunction ( $ object ) ; }
Traverse object to find children.

@param boolean $deep Should this call traverse deeply
@param AVObject|array &$object Object to traverse.
@param callable $mapFunction Function to call for every item.
@param array $seen Objects already seen.

@return mixed The result of calling mapFunction on the root object.
Traverse object to find children .