public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->path) && ($filter === null || isset($filter['path']))) {
			$packedBuffer = '';
			$output .= "\x0a";
			foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) {
				$packedBuffer .= Binary::encodeVarint($v);
			}
			$output .= Binary::encodeVarint(strlen($packedBuffer));
			$output .= $packedBuffer;
		}

		if (isset($object->span) && ($filter === null || isset($filter['span']))) {
			$packedBuffer = '';
			$output .= "\x12";
			foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) {
				$packedBuffer .= Binary::encodeVarint($v);
			}
			$output .= Binary::encodeVarint(strlen($packedBuffer));
			$output .= $packedBuffer;
		}

		if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) {
			$output .= "\x1a";
			$output .= Binary::encodeVarint(strlen($object->leadingComments));
			$output .= $object->leadingComments;
		}

		if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) {
			$output .= "\x22";
			$output .= Binary::encodeVarint(strlen($object->trailingComments));
			$output .= $object->trailingComments;
		}

		if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) {
			foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) {
				$output .= "\x32";
				$output .= Binary::encodeVarint(strlen($v));
				$output .= $v;
			}
		}

		return $output;
	}