/* Generated by Cython 0.29.14 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_14"
#define CYTHON_HEX_VERSION 0x001D0EF0
#define CYTHON_FUTURE_DIVISION 0
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
  #define PyObject_Unicode             PyObject_Str
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__breezy___known_graph_pyx
#define __PYX_HAVE_API__breezy___known_graph_pyx
/* Early includes */
#include "python-compat.h"
#include <string.h>
#include <stdio.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "breezy/_known_graph_pyx.pyx",
  "stringsource",
  "type.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode;
struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph;
struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode;
struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter;

/* "breezy/_known_graph_pyx.pyx":68
 * 
 * 
 * cdef class _KnownGraphNode:             # <<<<<<<<<<<<<<
 *     """Represents a single object in the known graph."""
 * 
 */
struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode {
  PyObject_HEAD
  struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_vtab;
  PyObject *key;
  PyObject *parents;
  PyObject *children;
  long gdfo;
  int seen;
  PyObject *extra;
};


/* "breezy/_known_graph_pyx.pyx":197
 * cdef class _MergeSorter
 * 
 * cdef class KnownGraph:             # <<<<<<<<<<<<<<
 *     """This is a class which assumes we already know the full graph."""
 * 
 */
struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph {
  PyObject_HEAD
  struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *__pyx_vtab;
  PyObject *_nodes;
  PyObject *_known_heads;
  int do_cache;
};


/* "breezy/_known_graph_pyx.pyx":673
 * 
 * 
 * cdef class _MergeSortNode:             # <<<<<<<<<<<<<<
 *     """Tracks information about a node during the merge_sort operation."""
 * 
 */
struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode {
  PyObject_HEAD
  struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_vtab;
  PyObject *key;
  long merge_depth;
  PyObject *end_of_merge;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *left_parent;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *left_pending_parent;
  PyObject *pending_parents;
  long _revno_first;
  long _revno_second;
  long _revno_last;
  int is_first_child;
  int seen_by_child;
  int completed;
};


/* "breezy/_known_graph_pyx.pyx":195
 * 
 * 
 * cdef class _MergeSorter             # <<<<<<<<<<<<<<
 * 
 * cdef class KnownGraph:
 */
struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter {
  PyObject_HEAD
  struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *__pyx_vtab;
  struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *graph;
  PyObject *_depth_first_stack;
  Py_ssize_t _last_stack_item;
  PyObject *_revno_to_branch_count;
  PyObject *_scheduled_nodes;
};



/* "breezy/_known_graph_pyx.pyx":68
 * 
 * 
 * cdef class _KnownGraphNode:             # <<<<<<<<<<<<<<
 *     """Represents a single object in the known graph."""
 * 
 */

struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__KnownGraphNode {
  PyObject *(*clear_references)(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *);
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_vtabptr_6breezy_16_known_graph_pyx__KnownGraphNode;


/* "breezy/_known_graph_pyx.pyx":731
 * 
 * 
 * cdef class _MergeSorter:             # <<<<<<<<<<<<<<
 *     """This class does the work of computing the merge_sort ordering.
 * 
 */

struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *(*_get_ms_node)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *);
  PyObject *(*_push_node)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *, long);
  PyObject *(*_pop_node)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *);
  PyObject *(*_schedule_stack)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *);
  PyObject *(*topo_order)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *);
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *__pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSorter;


/* "breezy/_known_graph_pyx.pyx":197
 * cdef class _MergeSorter
 * 
 * cdef class KnownGraph:             # <<<<<<<<<<<<<<
 *     """This is a class which assumes we already know the full graph."""
 * 
 */

struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *(*_get_or_create_node)(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *, PyObject *);
  PyObject *(*_populate_parents)(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *, PyObject *);
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *__pyx_vtabptr_6breezy_16_known_graph_pyx_KnownGraph;


/* "breezy/_known_graph_pyx.pyx":673
 * 
 * 
 * cdef class _MergeSortNode:             # <<<<<<<<<<<<<<
 *     """Tracks information about a node during the merge_sort operation."""
 * 
 */

struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode {
  int (*has_pending_parents)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *);
  PyObject *(*_revno)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *);
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSortNode;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* pyfrozenset_new.proto */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);

/* py_dict_pop.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* ListExtend.proto */
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject* none = _PyList_Extend((PyListObject*)L, v);
    if (unlikely(!none))
        return -1;
    Py_DECREF(none);
    return 0;
#else
    return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* pop.proto */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
#else
#define __Pyx_PyList_Pop(L)  __Pyx__PyObject_Pop(L)
#define __Pyx_PyObject_Pop(L)  __Pyx__PyObject_Pop(L)
#endif

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_15_KnownGraphNode_clear_references(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto*/
static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__get_or_create_node(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__populate_parents(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, PyObject *__pyx_v_parent_keys); /* proto*/
static int __pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode_has_pending_parents(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode__revno(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto*/
static struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__get_ms_node(CYTHON_UNUSED struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__push_node(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, long __pyx_v_merge_depth); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__pop_node(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__schedule_stack(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter_topo_order(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self); /* proto*/

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'breezy._known_graph_pyx' */
static PyTypeObject *__pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode = 0;
static PyTypeObject *__pyx_ptype_6breezy_16_known_graph_pyx__MergeSorter = 0;
static PyTypeObject *__pyx_ptype_6breezy_16_known_graph_pyx_KnownGraph = 0;
static PyTypeObject *__pyx_ptype_6breezy_16_known_graph_pyx__MergeSortNode = 0;
static PyObject *__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION = 0;
static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx__get_list_node(PyObject *, Py_ssize_t); /*proto*/
static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(PyObject *, Py_ssize_t); /*proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx__sort_list_nodes(PyObject *, int); /*proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__KnownGraphNode__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *, PyObject *); /*proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle_KnownGraph__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *, PyObject *); /*proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSortNode__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *, PyObject *); /*proto*/
static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSorter__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "breezy._known_graph_pyx"
extern int __pyx_module_is_main_breezy___known_graph_pyx;
int __pyx_module_is_main_breezy___known_graph_pyx = 0;

/* Implementation of 'breezy._known_graph_pyx' */
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_RuntimeError;
static const char __pyx_k__3[] = "";
static const char __pyx_k_gc[] = "gc";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_node[] = "node";
static const char __pyx_k_sort[] = "sort";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_clear[] = "clear";
static const char __pyx_k_deque[] = "deque";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_errors[] = "errors";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_get_key[] = "get_key";
static const char __pyx_k_popleft[] = "popleft";
static const char __pyx_k_reverse[] = "reverse";
static const char __pyx_k_tip_key[] = "tip_key";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_do_cache[] = "do_cache";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_revision[] = "revision";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_find_gdfo[] = "_find_gdfo";
static const char __pyx_k_find_tips[] = "_find_tips";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_real_node[] = "real_node";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_KnownGraph[] = "KnownGraph";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_child_keys[] = "child_keys";
static const char __pyx_k_find_tails[] = "_find_tails";
static const char __pyx_k_parent_map[] = "parent_map";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_MergeSorter[] = "_MergeSorter";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_known_graph[] = "known_graph";
static const char __pyx_k_parent_keys[] = "parent_keys";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_MergeSortNode[] = "_MergeSortNode";
static const char __pyx_k_NULL_REVISION[] = "NULL_REVISION";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_KnownGraphNode[] = "_KnownGraphNode";
static const char __pyx_k_GraphCycleError[] = "GraphCycleError";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_initialize_nodes[] = "_initialize_nodes";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_key_s_not_in_nodes[] = "key %s not in nodes";
static const char __pyx_k_Something_wrong_with_s[] = "Something wrong with: %s";
static const char __pyx_k_breezy__known_graph_pyx[] = "breezy._known_graph_pyx";
static const char __pyx_k_pyx_unpickle_KnownGraph[] = "__pyx_unpickle_KnownGraph";
static const char __pyx_k_s_s_gdfo_s_par_s_child_s[] = "%s(%s  gdfo:%s par:%s child:%s)";
static const char __pyx_k_pyx_unpickle__MergeSorter[] = "__pyx_unpickle__MergeSorter";
static const char __pyx_k_breezy__known_graph_pyx_pyx[] = "breezy/_known_graph_pyx.pyx";
static const char __pyx_k_pyx_unpickle__MergeSortNode[] = "__pyx_unpickle__MergeSortNode";
static const char __pyx_k_pyx_unpickle__KnownGraphNode[] = "__pyx_unpickle__KnownGraphNode";
static const char __pyx_k_s_s_depth_s_rev_s_s_s_first_s_s[] = "%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)";
static const char __pyx_k_Implementation_of_Graph_algorith[] = "Implementation of Graph algorithms when we have already loaded everything.\n";
static const char __pyx_k_Incompatible_checksums_s_vs_0x1d[] = "Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x6f[] = "Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x7a[] = "Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))";
static const char __pyx_k_Parent_key_mismatch_existing_nod[] = "Parent key mismatch, existing node %s has parents of %s not %s";
static const char __pyx_k_ghost_nodes_should_not_be_pushed[] = "ghost nodes should not be pushed onto the stack: %s";
static const char __pyx_k_lst_or_tpl_must_be_a_list_or_tup[] = "lst_or_tpl must be a list or tuple.";
static const char __pyx_k_parent_map_should_be_a_dict_of_k[] = "parent_map should be a dict of {key:parent_keys}";
static const char __pyx_k_Incompatible_checksums_s_vs_0x6f_2[] = "Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))";
static PyObject *__pyx_n_s_GraphCycleError;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x1d;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x6f;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x6f_2;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x7a;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_KnownGraph;
static PyObject *__pyx_n_s_KnownGraphNode;
static PyObject *__pyx_n_s_MergeSortNode;
static PyObject *__pyx_n_s_MergeSorter;
static PyObject *__pyx_n_s_NULL_REVISION;
static PyObject *__pyx_kp_s_Parent_key_mismatch_existing_nod;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_Something_wrong_with_s;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_breezy__known_graph_pyx;
static PyObject *__pyx_kp_s_breezy__known_graph_pyx_pyx;
static PyObject *__pyx_n_s_child_keys;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_deque;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_do_cache;
static PyObject *__pyx_n_s_errors;
static PyObject *__pyx_n_s_find_gdfo;
static PyObject *__pyx_n_s_find_tails;
static PyObject *__pyx_n_s_find_tips;
static PyObject *__pyx_n_s_gc;
static PyObject *__pyx_n_s_get_key;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_kp_s_ghost_nodes_should_not_be_pushed;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_initialize_nodes;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_kp_s_key_s_not_in_nodes;
static PyObject *__pyx_n_s_known_graph;
static PyObject *__pyx_kp_s_lst_or_tpl_must_be_a_list_or_tup;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_node;
static PyObject *__pyx_n_s_parent_keys;
static PyObject *__pyx_n_s_parent_map;
static PyObject *__pyx_kp_s_parent_map_should_be_a_dict_of_k;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_popleft;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_KnownGraph;
static PyObject *__pyx_n_s_pyx_unpickle__KnownGraphNode;
static PyObject *__pyx_n_s_pyx_unpickle__MergeSortNode;
static PyObject *__pyx_n_s_pyx_unpickle__MergeSorter;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_real_node;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_reverse;
static PyObject *__pyx_n_s_revision;
static PyObject *__pyx_kp_s_s_s_depth_s_rev_s_s_s_first_s_s;
static PyObject *__pyx_kp_s_s_s_gdfo_s_par_s_child_s;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_sort;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_tip_key;
static PyObject *__pyx_n_s_update;
static int __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_2__repr__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_6__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_get_key(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_node); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph___init__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_parent_map, PyObject *__pyx_v_do_cache); /* proto */
static void __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_2__dealloc__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_4_initialize_nodes(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_parent_map); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_find_tails(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8_find_tips(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_10_find_gdfo(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12add_node(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_parent_keys); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_14heads(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_keys); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_16topo_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_18gc_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_20merge_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_tip_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_22get_parent_keys(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_24get_child_keys(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_26__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_28__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_2__repr__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_4__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_6__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, PyObject *__pyx_v_known_graph, PyObject *__pyx_v_tip_key); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_2__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_4__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_2__pyx_unpickle__KnownGraphNode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_4__pyx_unpickle_KnownGraph(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_6__pyx_unpickle__MergeSortNode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_8__pyx_unpickle__MergeSorter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__KnownGraphNode(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__MergeSorter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx_KnownGraph(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__MergeSortNode(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_31173706;
static PyObject *__pyx_int_116732431;
static PyObject *__pyx_int_117422769;
static PyObject *__pyx_int_128118063;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_codeobj__5;
static PyObject *__pyx_codeobj__7;
static PyObject *__pyx_codeobj__9;
static PyObject *__pyx_codeobj__11;
static PyObject *__pyx_codeobj__13;
/* Late includes */

/* "breezy/_known_graph_pyx.pyx":78
 *     cdef object extra
 * 
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 *         self.key = key
 *         self.parents = None
 */

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 78, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 78, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode___init__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self), __pyx_v_key);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "breezy/_known_graph_pyx.pyx":79
 * 
 *     def __init__(self, key):
 *         self.key = key             # <<<<<<<<<<<<<<
 *         self.parents = None
 * 
 */
  __Pyx_INCREF(__pyx_v_key);
  __Pyx_GIVEREF(__pyx_v_key);
  __Pyx_GOTREF(__pyx_v_self->key);
  __Pyx_DECREF(__pyx_v_self->key);
  __pyx_v_self->key = __pyx_v_key;

  /* "breezy/_known_graph_pyx.pyx":80
 *     def __init__(self, key):
 *         self.key = key
 *         self.parents = None             # <<<<<<<<<<<<<<
 * 
 *         self.children = []
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->parents);
  __Pyx_DECREF(__pyx_v_self->parents);
  __pyx_v_self->parents = Py_None;

  /* "breezy/_known_graph_pyx.pyx":82
 *         self.parents = None
 * 
 *         self.children = []             # <<<<<<<<<<<<<<
 *         # Greatest distance from origin
 *         self.gdfo = -1
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->children);
  __Pyx_DECREF(__pyx_v_self->children);
  __pyx_v_self->children = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":84
 *         self.children = []
 *         # Greatest distance from origin
 *         self.gdfo = -1             # <<<<<<<<<<<<<<
 *         self.seen = 0
 *         self.extra = None
 */
  __pyx_v_self->gdfo = -1L;

  /* "breezy/_known_graph_pyx.pyx":85
 *         # Greatest distance from origin
 *         self.gdfo = -1
 *         self.seen = 0             # <<<<<<<<<<<<<<
 *         self.extra = None
 * 
 */
  __pyx_v_self->seen = 0;

  /* "breezy/_known_graph_pyx.pyx":86
 *         self.gdfo = -1
 *         self.seen = 0
 *         self.extra = None             # <<<<<<<<<<<<<<
 * 
 *     property child_keys:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->extra);
  __Pyx_DECREF(__pyx_v_self->extra);
  __pyx_v_self->extra = Py_None;

  /* "breezy/_known_graph_pyx.pyx":78
 *     cdef object extra
 * 
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 *         self.key = key
 *         self.parents = None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":89
 * 
 *     property child_keys:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _KnownGraphNode child
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_child = 0;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "breezy/_known_graph_pyx.pyx":92
 *             cdef _KnownGraphNode child
 * 
 *             keys = []             # <<<<<<<<<<<<<<
 *             for child in self.children:
 *                 PyList_Append(keys, child.key)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_keys = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":93
 * 
 *             keys = []
 *             for child in self.children:             # <<<<<<<<<<<<<<
 *                 PyList_Append(keys, child.key)
 *             return keys
 */
  if (likely(PyList_CheckExact(__pyx_v_self->children)) || PyTuple_CheckExact(__pyx_v_self->children)) {
    __pyx_t_1 = __pyx_v_self->children; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->children); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 93, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 93, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_child, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":94
 *             keys = []
 *             for child in self.children:
 *                 PyList_Append(keys, child.key)             # <<<<<<<<<<<<<<
 *             return keys
 * 
 */
    __pyx_t_4 = __pyx_v_child->key;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = PyList_Append(__pyx_v_keys, __pyx_t_4); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 94, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":93
 * 
 *             keys = []
 *             for child in self.children:             # <<<<<<<<<<<<<<
 *                 PyList_Append(keys, child.key)
 *             return keys
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":95
 *             for child in self.children:
 *                 PyList_Append(keys, child.key)
 *             return keys             # <<<<<<<<<<<<<<
 * 
 *     property parent_keys:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_keys);
  __pyx_r = __pyx_v_keys;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":89
 * 
 *     property child_keys:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _KnownGraphNode child
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.child_keys.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":98
 * 
 *     property parent_keys:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.parents is None:
 *                 return None
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent = 0;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "breezy/_known_graph_pyx.pyx":99
 *     property parent_keys:
 *         def __get__(self):
 *             if self.parents is None:             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
  __pyx_t_1 = (__pyx_v_self->parents == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":100
 *         def __get__(self):
 *             if self.parents is None:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             cdef _KnownGraphNode parent
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":99
 *     property parent_keys:
 *         def __get__(self):
 *             if self.parents is None:             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
  }

  /* "breezy/_known_graph_pyx.pyx":104
 *             cdef _KnownGraphNode parent
 * 
 *             keys = []             # <<<<<<<<<<<<<<
 *             for parent in self.parents:
 *                 PyList_Append(keys, parent.key)
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_keys = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "breezy/_known_graph_pyx.pyx":105
 * 
 *             keys = []
 *             for parent in self.parents:             # <<<<<<<<<<<<<<
 *                 PyList_Append(keys, parent.key)
 *             return keys
 */
  if (likely(PyList_CheckExact(__pyx_v_self->parents)) || PyTuple_CheckExact(__pyx_v_self->parents)) {
    __pyx_t_3 = __pyx_v_self->parents; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_self->parents); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 105, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 105, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 105, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 105, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_parent, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "breezy/_known_graph_pyx.pyx":106
 *             keys = []
 *             for parent in self.parents:
 *                 PyList_Append(keys, parent.key)             # <<<<<<<<<<<<<<
 *             return keys
 * 
 */
    __pyx_t_6 = __pyx_v_parent->key;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = PyList_Append(__pyx_v_keys, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "breezy/_known_graph_pyx.pyx":105
 * 
 *             keys = []
 *             for parent in self.parents:             # <<<<<<<<<<<<<<
 *                 PyList_Append(keys, parent.key)
 *             return keys
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "breezy/_known_graph_pyx.pyx":107
 *             for parent in self.parents:
 *                 PyList_Append(keys, parent.key)
 *             return keys             # <<<<<<<<<<<<<<
 * 
 *     cdef clear_references(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_keys);
  __pyx_r = __pyx_v_keys;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":98
 * 
 *     property parent_keys:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.parents is None:
 *                 return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.parent_keys.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_parent);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":109
 *             return keys
 * 
 *     cdef clear_references(self):             # <<<<<<<<<<<<<<
 *         self.parents = None
 *         self.children = None
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_15_KnownGraphNode_clear_references(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear_references", 0);

  /* "breezy/_known_graph_pyx.pyx":110
 * 
 *     cdef clear_references(self):
 *         self.parents = None             # <<<<<<<<<<<<<<
 *         self.children = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->parents);
  __Pyx_DECREF(__pyx_v_self->parents);
  __pyx_v_self->parents = Py_None;

  /* "breezy/_known_graph_pyx.pyx":111
 *     cdef clear_references(self):
 *         self.parents = None
 *         self.children = None             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->children);
  __Pyx_DECREF(__pyx_v_self->children);
  __pyx_v_self->children = Py_None;

  /* "breezy/_known_graph_pyx.pyx":109
 *             return keys
 * 
 *     cdef clear_references(self):             # <<<<<<<<<<<<<<
 *         self.parents = None
 *         self.children = None
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":113
 *         self.children = None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_2__repr__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_2__repr__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  PyObject *__pyx_v_parent_keys = NULL;
  PyObject *__pyx_v_child_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "breezy/_known_graph_pyx.pyx":116
 *         cdef _KnownGraphNode node
 * 
 *         parent_keys = []             # <<<<<<<<<<<<<<
 *         if self.parents is not None:
 *             for node in self.parents:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_parent_keys = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":117
 * 
 *         parent_keys = []
 *         if self.parents is not None:             # <<<<<<<<<<<<<<
 *             for node in self.parents:
 *                 parent_keys.append(node.key)
 */
  __pyx_t_2 = (__pyx_v_self->parents != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "breezy/_known_graph_pyx.pyx":118
 *         parent_keys = []
 *         if self.parents is not None:
 *             for node in self.parents:             # <<<<<<<<<<<<<<
 *                 parent_keys.append(node.key)
 *         child_keys = []
 */
    if (likely(PyList_CheckExact(__pyx_v_self->parents)) || PyTuple_CheckExact(__pyx_v_self->parents)) {
      __pyx_t_1 = __pyx_v_self->parents; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->parents); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 118, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 118, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 118, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_6));
      __pyx_t_6 = 0;

      /* "breezy/_known_graph_pyx.pyx":119
 *         if self.parents is not None:
 *             for node in self.parents:
 *                 parent_keys.append(node.key)             # <<<<<<<<<<<<<<
 *         child_keys = []
 *         if self.children is not None:
 */
      __pyx_t_6 = __pyx_v_node->key;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_parent_keys, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 119, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "breezy/_known_graph_pyx.pyx":118
 *         parent_keys = []
 *         if self.parents is not None:
 *             for node in self.parents:             # <<<<<<<<<<<<<<
 *                 parent_keys.append(node.key)
 *         child_keys = []
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":117
 * 
 *         parent_keys = []
 *         if self.parents is not None:             # <<<<<<<<<<<<<<
 *             for node in self.parents:
 *                 parent_keys.append(node.key)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":120
 *             for node in self.parents:
 *                 parent_keys.append(node.key)
 *         child_keys = []             # <<<<<<<<<<<<<<
 *         if self.children is not None:
 *             for node in self.children:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_child_keys = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":121
 *                 parent_keys.append(node.key)
 *         child_keys = []
 *         if self.children is not None:             # <<<<<<<<<<<<<<
 *             for node in self.children:
 *                 child_keys.append(node.key)
 */
  __pyx_t_3 = (__pyx_v_self->children != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":122
 *         child_keys = []
 *         if self.children is not None:
 *             for node in self.children:             # <<<<<<<<<<<<<<
 *                 child_keys.append(node.key)
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 */
    if (likely(PyList_CheckExact(__pyx_v_self->children)) || PyTuple_CheckExact(__pyx_v_self->children)) {
      __pyx_t_1 = __pyx_v_self->children; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->children); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 122, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 122, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 122, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 122, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 122, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_6));
      __pyx_t_6 = 0;

      /* "breezy/_known_graph_pyx.pyx":123
 *         if self.children is not None:
 *             for node in self.children:
 *                 child_keys.append(node.key)             # <<<<<<<<<<<<<<
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 *             self.__class__.__name__, self.key, self.gdfo,
 */
      __pyx_t_6 = __pyx_v_node->key;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_child_keys, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 123, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "breezy/_known_graph_pyx.pyx":122
 *         child_keys = []
 *         if self.children is not None:
 *             for node in self.children:             # <<<<<<<<<<<<<<
 *                 child_keys.append(node.key)
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":121
 *                 parent_keys.append(node.key)
 *         child_keys = []
 *         if self.children is not None:             # <<<<<<<<<<<<<<
 *             for node in self.children:
 *                 child_keys.append(node.key)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":124
 *             for node in self.children:
 *                 child_keys.append(node.key)
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (             # <<<<<<<<<<<<<<
 *             self.__class__.__name__, self.key, self.gdfo,
 *             parent_keys, child_keys)
 */
  __Pyx_XDECREF(__pyx_r);

  /* "breezy/_known_graph_pyx.pyx":125
 *                 child_keys.append(node.key)
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 *             self.__class__.__name__, self.key, self.gdfo,             # <<<<<<<<<<<<<<
 *             parent_keys, child_keys)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->gdfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "breezy/_known_graph_pyx.pyx":126
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 *             self.__class__.__name__, self.key, self.gdfo,
 *             parent_keys, child_keys)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
  __Pyx_INCREF(__pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_v_self->key);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_parent_keys);
  __Pyx_GIVEREF(__pyx_v_parent_keys);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_parent_keys);
  __Pyx_INCREF(__pyx_v_child_keys);
  __Pyx_GIVEREF(__pyx_v_child_keys);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_child_keys);
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":124
 *             for node in self.children:
 *                 child_keys.append(node.key)
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (             # <<<<<<<<<<<<<<
 *             self.__class__.__name__, self.key, self.gdfo,
 *             parent_keys, child_keys)
 */
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_s_gdfo_s_par_s_child_s, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":113
 *         self.children = None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_parent_keys);
  __Pyx_XDECREF(__pyx_v_child_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":74
 *     cdef object parents
 *     cdef object children
 *     cdef public long gdfo             # <<<<<<<<<<<<<<
 *     cdef int seen
 *     cdef object extra
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->gdfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.gdfo.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_value); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_v_self->gdfo = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.gdfo.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4__reduce_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_4__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.children, self.extra, self.gdfo, self.key, self.parents, self.seen)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->gdfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->seen); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->children);
  __Pyx_GIVEREF(__pyx_v_self->children);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->children);
  __Pyx_INCREF(__pyx_v_self->extra);
  __Pyx_GIVEREF(__pyx_v_self->extra);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->extra);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_v_self->key);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->key);
  __Pyx_INCREF(__pyx_v_self->parents);
  __Pyx_GIVEREF(__pyx_v_self->parents);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_self->parents);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.children, self.extra, self.gdfo, self.key, self.parents, self.seen)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":7
 *     state = (self.children, self.extra, self.gdfo, self.key, self.parents, self.seen)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.children is not None or self.extra is not None or self.key is not None or self.parents is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.children, self.extra, self.gdfo, self.key, self.parents, self.seen)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.children is not None or self.extra is not None or self.key is not None or self.parents is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->children != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->extra != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->key != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->parents != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.children is not None or self.extra is not None or self.key is not None or self.parents is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":13
 *         use_setstate = self.children is not None or self.extra is not None or self.key is not None or self.parents is not None
 *     if use_setstate:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle__KnownGraphNode); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_31173706);
    __Pyx_GIVEREF(__pyx_int_31173706);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_31173706);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.children is not None or self.extra is not None or self.key is not None or self.parents is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, None), state
 *     else:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__KnownGraphNode__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle__KnownGraphNode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_31173706);
    __Pyx_GIVEREF(__pyx_int_31173706);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_31173706);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__KnownGraphNode__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_6__setstate_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_15_KnownGraphNode_6__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__KnownGraphNode__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__KnownGraphNode__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__KnownGraphNode, (type(self), 0x1dbac4a, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__KnownGraphNode__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._KnownGraphNode.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":129
 * 
 * 
 * cdef _KnownGraphNode _get_list_node(lst, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 *     cdef PyObject *temp_node
 * 
 */

static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx__get_list_node(PyObject *__pyx_v_lst, Py_ssize_t __pyx_v_pos) {
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_list_node", 0);

  /* "breezy/_known_graph_pyx.pyx":132
 *     cdef PyObject *temp_node
 * 
 *     temp_node = PyList_GET_ITEM(lst, pos)             # <<<<<<<<<<<<<<
 *     return <_KnownGraphNode>temp_node
 * 
 */
  __pyx_v_temp_node = PyList_GET_ITEM(__pyx_v_lst, __pyx_v_pos);

  /* "breezy/_known_graph_pyx.pyx":133
 * 
 *     temp_node = PyList_GET_ITEM(lst, pos)
 *     return <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
  __pyx_r = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":129
 * 
 * 
 * cdef _KnownGraphNode _get_list_node(lst, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 *     cdef PyObject *temp_node
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":136
 * 
 * 
 * cdef _KnownGraphNode _get_tuple_node(tpl, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 *     cdef PyObject *temp_node
 * 
 */

static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(PyObject *__pyx_v_tpl, Py_ssize_t __pyx_v_pos) {
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_tuple_node", 0);

  /* "breezy/_known_graph_pyx.pyx":139
 *     cdef PyObject *temp_node
 * 
 *     temp_node = PyTuple_GET_ITEM(tpl, pos)             # <<<<<<<<<<<<<<
 *     return <_KnownGraphNode>temp_node
 * 
 */
  __pyx_v_temp_node = PyTuple_GET_ITEM(__pyx_v_tpl, __pyx_v_pos);

  /* "breezy/_known_graph_pyx.pyx":140
 * 
 *     temp_node = PyTuple_GET_ITEM(tpl, pos)
 *     return <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
  __pyx_r = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":136
 * 
 * 
 * cdef _KnownGraphNode _get_tuple_node(tpl, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 *     cdef PyObject *temp_node
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":143
 * 
 * 
 * def get_key(node):             # <<<<<<<<<<<<<<
 *     cdef _KnownGraphNode real_node
 *     real_node = node
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_1get_key(PyObject *__pyx_self, PyObject *__pyx_v_node); /*proto*/
static PyMethodDef __pyx_mdef_6breezy_16_known_graph_pyx_1get_key = {"get_key", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_1get_key, METH_O, 0};
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_1get_key(PyObject *__pyx_self, PyObject *__pyx_v_node) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_key (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_get_key(__pyx_self, ((PyObject *)__pyx_v_node));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_get_key(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_node) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_real_node = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_key", 0);

  /* "breezy/_known_graph_pyx.pyx":145
 * def get_key(node):
 *     cdef _KnownGraphNode real_node
 *     real_node = node             # <<<<<<<<<<<<<<
 *     return real_node.key
 * 
 */
  if (!(likely(((__pyx_v_node) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_node, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 145, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_node;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_real_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":146
 *     cdef _KnownGraphNode real_node
 *     real_node = node
 *     return real_node.key             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_real_node->key);
  __pyx_r = __pyx_v_real_node->key;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":143
 * 
 * 
 * def get_key(node):             # <<<<<<<<<<<<<<
 *     cdef _KnownGraphNode real_node
 *     real_node = node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.get_key", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_real_node);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":149
 * 
 * 
 * cdef object _sort_list_nodes(object lst_or_tpl, int reverse):             # <<<<<<<<<<<<<<
 *     """Sort a list of _KnownGraphNode objects.
 * 
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx__sort_list_nodes(PyObject *__pyx_v_lst_or_tpl, int __pyx_v_reverse) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node1 = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node2 = 0;
  int __pyx_v_do_swap;
  int __pyx_v_is_tuple;
  Py_ssize_t __pyx_v_length;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_sort_list_nodes", 0);
  __Pyx_INCREF(__pyx_v_lst_or_tpl);

  /* "breezy/_known_graph_pyx.pyx":159
 *     cdef Py_ssize_t length
 * 
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)             # <<<<<<<<<<<<<<
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 */
  __pyx_v_is_tuple = PyTuple_CheckExact(__pyx_v_lst_or_tpl);

  /* "breezy/_known_graph_pyx.pyx":160
 * 
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):             # <<<<<<<<<<<<<<
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 *     length = len(lst_or_tpl)
 */
  __pyx_t_2 = (__pyx_v_is_tuple != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (PyList_CheckExact(__pyx_v_lst_or_tpl) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "breezy/_known_graph_pyx.pyx":161
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 *         raise TypeError('lst_or_tpl must be a list or tuple.')             # <<<<<<<<<<<<<<
 *     length = len(lst_or_tpl)
 *     if length == 0 or length == 1:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 161, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":160
 * 
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):             # <<<<<<<<<<<<<<
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 *     length = len(lst_or_tpl)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":162
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 *     length = len(lst_or_tpl)             # <<<<<<<<<<<<<<
 *     if length == 0 or length == 1:
 *         return lst_or_tpl
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_lst_or_tpl); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 162, __pyx_L1_error)
  __pyx_v_length = __pyx_t_4;

  /* "breezy/_known_graph_pyx.pyx":163
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 *     length = len(lst_or_tpl)
 *     if length == 0 or length == 1:             # <<<<<<<<<<<<<<
 *         return lst_or_tpl
 *     if length == 2:
 */
  switch (__pyx_v_length) {
    case 0:
    case 1:

    /* "breezy/_known_graph_pyx.pyx":164
 *     length = len(lst_or_tpl)
 *     if length == 0 or length == 1:
 *         return lst_or_tpl             # <<<<<<<<<<<<<<
 *     if length == 2:
 *         if is_tuple:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_lst_or_tpl);
    __pyx_r = __pyx_v_lst_or_tpl;
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":163
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 *     length = len(lst_or_tpl)
 *     if length == 0 or length == 1:             # <<<<<<<<<<<<<<
 *         return lst_or_tpl
 *     if length == 2:
 */
    break;
    default: break;
  }

  /* "breezy/_known_graph_pyx.pyx":165
 *     if length == 0 or length == 1:
 *         return lst_or_tpl
 *     if length == 2:             # <<<<<<<<<<<<<<
 *         if is_tuple:
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 */
  __pyx_t_2 = ((__pyx_v_length == 2) != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":166
 *         return lst_or_tpl
 *     if length == 2:
 *         if is_tuple:             # <<<<<<<<<<<<<<
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 */
    __pyx_t_2 = (__pyx_v_is_tuple != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":167
 *     if length == 2:
 *         if is_tuple:
 *             node1 = _get_tuple_node(lst_or_tpl, 0)             # <<<<<<<<<<<<<<
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 *         else:
 */
      __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_v_lst_or_tpl, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_node1 = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":168
 *         if is_tuple:
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 *             node2 = _get_tuple_node(lst_or_tpl, 1)             # <<<<<<<<<<<<<<
 *         else:
 *             node1 = _get_list_node(lst_or_tpl, 0)
 */
      __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_v_lst_or_tpl, 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_node2 = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":166
 *         return lst_or_tpl
 *     if length == 2:
 *         if is_tuple:             # <<<<<<<<<<<<<<
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 */
      goto __pyx_L7;
    }

    /* "breezy/_known_graph_pyx.pyx":170
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 *         else:
 *             node1 = _get_list_node(lst_or_tpl, 0)             # <<<<<<<<<<<<<<
 *             node2 = _get_list_node(lst_or_tpl, 1)
 *         if reverse:
 */
    /*else*/ {
      __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_lst_or_tpl, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_node1 = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":171
 *         else:
 *             node1 = _get_list_node(lst_or_tpl, 0)
 *             node2 = _get_list_node(lst_or_tpl, 1)             # <<<<<<<<<<<<<<
 *         if reverse:
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 */
      __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_lst_or_tpl, 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_node2 = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L7:;

    /* "breezy/_known_graph_pyx.pyx":172
 *             node1 = _get_list_node(lst_or_tpl, 0)
 *             node2 = _get_list_node(lst_or_tpl, 1)
 *         if reverse:             # <<<<<<<<<<<<<<
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 *         else:
 */
    __pyx_t_2 = (__pyx_v_reverse != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":173
 *             node2 = _get_list_node(lst_or_tpl, 1)
 *         if reverse:
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)             # <<<<<<<<<<<<<<
 *         else:
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 */
      __pyx_t_3 = __pyx_v_node1->key;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_5 = __pyx_v_node2->key;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_2 = PyObject_RichCompareBool(__pyx_t_3, __pyx_t_5, Py_LT); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_do_swap = __pyx_t_2;

      /* "breezy/_known_graph_pyx.pyx":172
 *             node1 = _get_list_node(lst_or_tpl, 0)
 *             node2 = _get_list_node(lst_or_tpl, 1)
 *         if reverse:             # <<<<<<<<<<<<<<
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 *         else:
 */
      goto __pyx_L8;
    }

    /* "breezy/_known_graph_pyx.pyx":175
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 *         else:
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)             # <<<<<<<<<<<<<<
 *         if not do_swap:
 *             return lst_or_tpl
 */
    /*else*/ {
      __pyx_t_5 = __pyx_v_node2->key;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_3 = __pyx_v_node1->key;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_2 = PyObject_RichCompareBool(__pyx_t_5, __pyx_t_3, Py_LT); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 175, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_do_swap = __pyx_t_2;
    }
    __pyx_L8:;

    /* "breezy/_known_graph_pyx.pyx":176
 *         else:
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 *         if not do_swap:             # <<<<<<<<<<<<<<
 *             return lst_or_tpl
 *         if is_tuple:
 */
    __pyx_t_2 = ((!(__pyx_v_do_swap != 0)) != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":177
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 *         if not do_swap:
 *             return lst_or_tpl             # <<<<<<<<<<<<<<
 *         if is_tuple:
 *             return (node2, node1)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_lst_or_tpl);
      __pyx_r = __pyx_v_lst_or_tpl;
      goto __pyx_L0;

      /* "breezy/_known_graph_pyx.pyx":176
 *         else:
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 *         if not do_swap:             # <<<<<<<<<<<<<<
 *             return lst_or_tpl
 *         if is_tuple:
 */
    }

    /* "breezy/_known_graph_pyx.pyx":178
 *         if not do_swap:
 *             return lst_or_tpl
 *         if is_tuple:             # <<<<<<<<<<<<<<
 *             return (node2, node1)
 *         else:
 */
    __pyx_t_2 = (__pyx_v_is_tuple != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":179
 *             return lst_or_tpl
 *         if is_tuple:
 *             return (node2, node1)             # <<<<<<<<<<<<<<
 *         else:
 *             # Swap 'in-place', since lists are mutable
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_node2));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node2));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_node2));
      __Pyx_INCREF(((PyObject *)__pyx_v_node1));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node1));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_node1));
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "breezy/_known_graph_pyx.pyx":178
 *         if not do_swap:
 *             return lst_or_tpl
 *         if is_tuple:             # <<<<<<<<<<<<<<
 *             return (node2, node1)
 *         else:
 */
    }

    /* "breezy/_known_graph_pyx.pyx":182
 *         else:
 *             # Swap 'in-place', since lists are mutable
 *             Py_INCREF(node1)             # <<<<<<<<<<<<<<
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 *             Py_INCREF(node2)
 */
    /*else*/ {
      Py_INCREF(((PyObject *)__pyx_v_node1));

      /* "breezy/_known_graph_pyx.pyx":183
 *             # Swap 'in-place', since lists are mutable
 *             Py_INCREF(node1)
 *             PyList_SetItem(lst_or_tpl, 1, node1)             # <<<<<<<<<<<<<<
 *             Py_INCREF(node2)
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 */
      __pyx_t_6 = PyList_SetItem(__pyx_v_lst_or_tpl, 1, ((PyObject *)__pyx_v_node1)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 183, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":184
 *             Py_INCREF(node1)
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 *             Py_INCREF(node2)             # <<<<<<<<<<<<<<
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 *             return lst_or_tpl
 */
      Py_INCREF(((PyObject *)__pyx_v_node2));

      /* "breezy/_known_graph_pyx.pyx":185
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 *             Py_INCREF(node2)
 *             PyList_SetItem(lst_or_tpl, 0, node2)             # <<<<<<<<<<<<<<
 *             return lst_or_tpl
 *     # For all other sizes, we just use 'sorted()'
 */
      __pyx_t_6 = PyList_SetItem(__pyx_v_lst_or_tpl, 0, ((PyObject *)__pyx_v_node2)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 185, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":186
 *             Py_INCREF(node2)
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 *             return lst_or_tpl             # <<<<<<<<<<<<<<
 *     # For all other sizes, we just use 'sorted()'
 *     if is_tuple:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_lst_or_tpl);
      __pyx_r = __pyx_v_lst_or_tpl;
      goto __pyx_L0;
    }

    /* "breezy/_known_graph_pyx.pyx":165
 *     if length == 0 or length == 1:
 *         return lst_or_tpl
 *     if length == 2:             # <<<<<<<<<<<<<<
 *         if is_tuple:
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":188
 *             return lst_or_tpl
 *     # For all other sizes, we just use 'sorted()'
 *     if is_tuple:             # <<<<<<<<<<<<<<
 *         # Note that sorted() is just list(iterable).sort()
 *         lst_or_tpl = list(lst_or_tpl)
 */
  __pyx_t_2 = (__pyx_v_is_tuple != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":190
 *     if is_tuple:
 *         # Note that sorted() is just list(iterable).sort()
 *         lst_or_tpl = list(lst_or_tpl)             # <<<<<<<<<<<<<<
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)
 *     return lst_or_tpl
 */
    __pyx_t_3 = PySequence_List(__pyx_v_lst_or_tpl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_lst_or_tpl, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":188
 *             return lst_or_tpl
 *     # For all other sizes, we just use 'sorted()'
 *     if is_tuple:             # <<<<<<<<<<<<<<
 *         # Note that sorted() is just list(iterable).sort()
 *         lst_or_tpl = list(lst_or_tpl)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":191
 *         # Note that sorted() is just list(iterable).sort()
 *         lst_or_tpl = list(lst_or_tpl)
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)             # <<<<<<<<<<<<<<
 *     return lst_or_tpl
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_lst_or_tpl, __pyx_n_s_sort); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_7) < 0) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_reverse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_t_7) < 0) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "breezy/_known_graph_pyx.pyx":192
 *         lst_or_tpl = list(lst_or_tpl)
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)
 *     return lst_or_tpl             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_lst_or_tpl);
  __pyx_r = __pyx_v_lst_or_tpl;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":149
 * 
 * 
 * cdef object _sort_list_nodes(object lst_or_tpl, int reverse):             # <<<<<<<<<<<<<<
 *     """Sort a list of _KnownGraphNode objects.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("breezy._known_graph_pyx._sort_list_nodes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node1);
  __Pyx_XDECREF((PyObject *)__pyx_v_node2);
  __Pyx_XDECREF(__pyx_v_lst_or_tpl);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":204
 *     cdef public int do_cache
 * 
 *     def __init__(self, parent_map, do_cache=True):             # <<<<<<<<<<<<<<
 *         """Create a new KnownGraph instance.
 * 
 */

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph___init__[] = "Create a new KnownGraph instance.\n\n        :param parent_map: A dictionary mapping key => parent_keys\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_6breezy_16_known_graph_pyx_10KnownGraph___init__;
#endif
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parent_map = 0;
  PyObject *__pyx_v_do_cache = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_parent_map,&__pyx_n_s_do_cache,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parent_map)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_do_cache);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 204, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_parent_map = values[0];
    __pyx_v_do_cache = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 204, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph___init__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_parent_map, __pyx_v_do_cache);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph___init__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_parent_map, PyObject *__pyx_v_do_cache) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "breezy/_known_graph_pyx.pyx":210
 *         """
 *         # tests at pre-allocating the node dict actually slowed things down
 *         self._nodes = {}             # <<<<<<<<<<<<<<
 *         # Maps {sorted(revision_id, revision_id): heads}
 *         self._known_heads = {}
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_nodes);
  __Pyx_DECREF(__pyx_v_self->_nodes);
  __pyx_v_self->_nodes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":212
 *         self._nodes = {}
 *         # Maps {sorted(revision_id, revision_id): heads}
 *         self._known_heads = {}             # <<<<<<<<<<<<<<
 *         self.do_cache = int(do_cache)
 *         # TODO: consider disabling gc since we are allocating a lot of nodes
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_known_heads);
  __Pyx_DECREF(__pyx_v_self->_known_heads);
  __pyx_v_self->_known_heads = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":213
 *         # Maps {sorted(revision_id, revision_id): heads}
 *         self._known_heads = {}
 *         self.do_cache = int(do_cache)             # <<<<<<<<<<<<<<
 *         # TODO: consider disabling gc since we are allocating a lot of nodes
 *         #       that won't be collectable anyway. real world testing has not
 */
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_do_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->do_cache = __pyx_t_2;

  /* "breezy/_known_graph_pyx.pyx":217
 *         #       that won't be collectable anyway. real world testing has not
 *         #       shown a specific impact, yet.
 *         self._initialize_nodes(parent_map)             # <<<<<<<<<<<<<<
 *         self._find_gdfo()
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_initialize_nodes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_parent_map) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_parent_map);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":218
 *         #       shown a specific impact, yet.
 *         self._initialize_nodes(parent_map)
 *         self._find_gdfo()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_gdfo); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":204
 *     cdef public int do_cache
 * 
 *     def __init__(self, parent_map, do_cache=True):             # <<<<<<<<<<<<<<
 *         """Create a new KnownGraph instance.
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":220
 *         self._find_gdfo()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode child
 *         cdef Py_ssize_t pos
 */

/* Python wrapper */
static void __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_2__dealloc__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_2__dealloc__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_child = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_temp_node;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "breezy/_known_graph_pyx.pyx":225
 *         cdef PyObject *temp_node
 * 
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 *             child = <_KnownGraphNode>temp_node
 *             child.clear_references()
 */
  while (1) {
    __pyx_t_1 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = (PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node)) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":226
 * 
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             child = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *             child.clear_references()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_child, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":227
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             child = <_KnownGraphNode>temp_node
 *             child.clear_references()             # <<<<<<<<<<<<<<
 * 
 *     cdef _KnownGraphNode _get_or_create_node(self, key):
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v_child->__pyx_vtab)->clear_references(__pyx_v_child); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "breezy/_known_graph_pyx.pyx":220
 *         self._find_gdfo()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode child
 *         cdef Py_ssize_t pos
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("breezy._known_graph_pyx.KnownGraph.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_RefNannyFinishContext();
}

/* "breezy/_known_graph_pyx.pyx":229
 *             child.clear_references()
 * 
 *     cdef _KnownGraphNode _get_or_create_node(self, key):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

static struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__get_or_create_node(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_get_or_create_node", 0);

  /* "breezy/_known_graph_pyx.pyx":233
 *         cdef _KnownGraphNode node
 * 
 *         temp_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 *         if temp_node == NULL:
 *             node = _KnownGraphNode(key)
 */
  __pyx_t_1 = __pyx_v_self->_nodes;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_temp_node = PyDict_GetItem(__pyx_t_1, __pyx_v_key);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":234
 * 
 *         temp_node = PyDict_GetItem(self._nodes, key)
 *         if temp_node == NULL:             # <<<<<<<<<<<<<<
 *             node = _KnownGraphNode(key)
 *             PyDict_SetItem(self._nodes, key, node)
 */
  __pyx_t_2 = ((__pyx_v_temp_node == NULL) != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":235
 *         temp_node = PyDict_GetItem(self._nodes, key)
 *         if temp_node == NULL:
 *             node = _KnownGraphNode(key)             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(self._nodes, key, node)
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode), __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":236
 *         if temp_node == NULL:
 *             node = _KnownGraphNode(key)
 *             PyDict_SetItem(self._nodes, key, node)             # <<<<<<<<<<<<<<
 *         else:
 *             node = <_KnownGraphNode>temp_node
 */
    __pyx_t_1 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = PyDict_SetItem(__pyx_t_1, __pyx_v_key, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 236, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":234
 * 
 *         temp_node = PyDict_GetItem(self._nodes, key)
 *         if temp_node == NULL:             # <<<<<<<<<<<<<<
 *             node = _KnownGraphNode(key)
 *             PyDict_SetItem(self._nodes, key, node)
 */
    goto __pyx_L3;
  }

  /* "breezy/_known_graph_pyx.pyx":238
 *             PyDict_SetItem(self._nodes, key, node)
 *         else:
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *         return node
 * 
 */
  /*else*/ {
    __pyx_t_1 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "breezy/_known_graph_pyx.pyx":239
 *         else:
 *             node = <_KnownGraphNode>temp_node
 *         return node             # <<<<<<<<<<<<<<
 * 
 *     cdef _populate_parents(self, _KnownGraphNode node, parent_keys):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_node));
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":229
 *             child.clear_references()
 * 
 *     cdef _KnownGraphNode _get_or_create_node(self, key):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._get_or_create_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":241
 *         return node
 * 
 *     cdef _populate_parents(self, _KnownGraphNode node, parent_keys):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t num_parent_keys, pos
 *         cdef _KnownGraphNode parent_node
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__populate_parents(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, PyObject *__pyx_v_parent_keys) {
  Py_ssize_t __pyx_v_num_parent_keys;
  Py_ssize_t __pyx_v_pos;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node = 0;
  PyObject *__pyx_v_parent_nodes = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_populate_parents", 0);

  /* "breezy/_known_graph_pyx.pyx":245
 *         cdef _KnownGraphNode parent_node
 * 
 *         num_parent_keys = len(parent_keys)             # <<<<<<<<<<<<<<
 *         # We know how many parents, so we pre allocate the tuple
 *         parent_nodes = PyTuple_New(num_parent_keys)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_parent_keys); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 245, __pyx_L1_error)
  __pyx_v_num_parent_keys = __pyx_t_1;

  /* "breezy/_known_graph_pyx.pyx":247
 *         num_parent_keys = len(parent_keys)
 *         # We know how many parents, so we pre allocate the tuple
 *         parent_nodes = PyTuple_New(num_parent_keys)             # <<<<<<<<<<<<<<
 *         for pos from 0 <= pos < num_parent_keys:
 *             # Note: it costs us 10ms out of 40ms to lookup all of these
 */
  __pyx_t_2 = PyTuple_New(__pyx_v_num_parent_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_parent_nodes = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":248
 *         # We know how many parents, so we pre allocate the tuple
 *         parent_nodes = PyTuple_New(num_parent_keys)
 *         for pos from 0 <= pos < num_parent_keys:             # <<<<<<<<<<<<<<
 *             # Note: it costs us 10ms out of 40ms to lookup all of these
 *             #       parents, it doesn't seem to be an allocation overhead,
 */
  __pyx_t_1 = __pyx_v_num_parent_keys;
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_1; __pyx_v_pos++) {

    /* "breezy/_known_graph_pyx.pyx":256
 *             #       node.
 *             # We use [] because parent_keys may be a tuple or list
 *             parent_node = self._get_or_create_node(parent_keys[pos])             # <<<<<<<<<<<<<<
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 *             Py_INCREF(parent_node)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parent_keys, __pyx_v_pos, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_get_or_create_node(__pyx_v_self, __pyx_t_2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":258
 *             parent_node = self._get_or_create_node(parent_keys[pos])
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 *             Py_INCREF(parent_node)             # <<<<<<<<<<<<<<
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 *             PyList_Append(parent_node.children, node)
 */
    Py_INCREF(((PyObject *)__pyx_v_parent_node));

    /* "breezy/_known_graph_pyx.pyx":259
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 *             Py_INCREF(parent_node)
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)             # <<<<<<<<<<<<<<
 *             PyList_Append(parent_node.children, node)
 *         node.parents = parent_nodes
 */
    PyTuple_SET_ITEM(__pyx_v_parent_nodes, __pyx_v_pos, ((PyObject *)__pyx_v_parent_node));

    /* "breezy/_known_graph_pyx.pyx":260
 *             Py_INCREF(parent_node)
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 *             PyList_Append(parent_node.children, node)             # <<<<<<<<<<<<<<
 *         node.parents = parent_nodes
 * 
 */
    __pyx_t_3 = __pyx_v_parent_node->children;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_4 = PyList_Append(__pyx_t_3, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "breezy/_known_graph_pyx.pyx":261
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 *             PyList_Append(parent_node.children, node)
 *         node.parents = parent_nodes             # <<<<<<<<<<<<<<
 * 
 *     def _initialize_nodes(self, parent_map):
 */
  __Pyx_INCREF(__pyx_v_parent_nodes);
  __Pyx_GIVEREF(__pyx_v_parent_nodes);
  __Pyx_GOTREF(__pyx_v_node->parents);
  __Pyx_DECREF(__pyx_v_node->parents);
  __pyx_v_node->parents = __pyx_v_parent_nodes;

  /* "breezy/_known_graph_pyx.pyx":241
 *         return node
 * 
 *     cdef _populate_parents(self, _KnownGraphNode node, parent_keys):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t num_parent_keys, pos
 *         cdef _KnownGraphNode parent_node
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._populate_parents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_node);
  __Pyx_XDECREF(__pyx_v_parent_nodes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":263
 *         node.parents = parent_nodes
 * 
 *     def _initialize_nodes(self, parent_map):             # <<<<<<<<<<<<<<
 *         """Populate self._nodes.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_5_initialize_nodes(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_map); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_4_initialize_nodes[] = "Populate self._nodes.\n\n        After this has finished:\n        - self._nodes will have an entry for every entry in parent_map.\n        - ghosts will have a parent_keys = None,\n        - all nodes found will also have child_keys populated with all known\n          child keys,\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_5_initialize_nodes(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_map) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_initialize_nodes (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_4_initialize_nodes(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_parent_map));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_4_initialize_nodes(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_parent_map) {
  PyObject *__pyx_v_temp_key;
  PyObject *__pyx_v_temp_parent_keys;
  Py_ssize_t __pyx_v_pos;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_parent_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_initialize_nodes", 0);

  /* "breezy/_known_graph_pyx.pyx":279
 *         cdef _KnownGraphNode parent_node
 * 
 *         if not PyDict_CheckExact(parent_map):             # <<<<<<<<<<<<<<
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')
 *         # for key, parent_keys in parent_map.iteritems():
 */
  __pyx_t_1 = ((!(PyDict_CheckExact(__pyx_v_parent_map) != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "breezy/_known_graph_pyx.pyx":280
 * 
 *         if not PyDict_CheckExact(parent_map):
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')             # <<<<<<<<<<<<<<
 *         # for key, parent_keys in parent_map.iteritems():
 *         pos = 0
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 280, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":279
 *         cdef _KnownGraphNode parent_node
 * 
 *         if not PyDict_CheckExact(parent_map):             # <<<<<<<<<<<<<<
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')
 *         # for key, parent_keys in parent_map.iteritems():
 */
  }

  /* "breezy/_known_graph_pyx.pyx":282
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')
 *         # for key, parent_keys in parent_map.iteritems():
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 *             key = <object>temp_key
 */
  __pyx_v_pos = 0;

  /* "breezy/_known_graph_pyx.pyx":283
 *         # for key, parent_keys in parent_map.iteritems():
 *         pos = 0
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):             # <<<<<<<<<<<<<<
 *             key = <object>temp_key
 *             parent_keys = <object>temp_parent_keys
 */
  while (1) {
    __pyx_t_1 = (PyDict_Next(__pyx_v_parent_map, (&__pyx_v_pos), (&__pyx_v_temp_key), (&__pyx_v_temp_parent_keys)) != 0);
    if (!__pyx_t_1) break;

    /* "breezy/_known_graph_pyx.pyx":284
 *         pos = 0
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 *             key = <object>temp_key             # <<<<<<<<<<<<<<
 *             parent_keys = <object>temp_parent_keys
 *             node = self._get_or_create_node(key)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_temp_key);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "breezy/_known_graph_pyx.pyx":285
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 *             key = <object>temp_key
 *             parent_keys = <object>temp_parent_keys             # <<<<<<<<<<<<<<
 *             node = self._get_or_create_node(key)
 *             self._populate_parents(node, parent_keys)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_temp_parent_keys);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_parent_keys, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "breezy/_known_graph_pyx.pyx":286
 *             key = <object>temp_key
 *             parent_keys = <object>temp_parent_keys
 *             node = self._get_or_create_node(key)             # <<<<<<<<<<<<<<
 *             self._populate_parents(node, parent_keys)
 * 
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_get_or_create_node(__pyx_v_self, __pyx_v_key)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "breezy/_known_graph_pyx.pyx":287
 *             parent_keys = <object>temp_parent_keys
 *             node = self._get_or_create_node(key)
 *             self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 * 
 *     def _find_tails(self):
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_populate_parents(__pyx_v_self, __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "breezy/_known_graph_pyx.pyx":263
 *         node.parents = parent_nodes
 * 
 *     def _initialize_nodes(self, parent_map):             # <<<<<<<<<<<<<<
 *         """Populate self._nodes.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._initialize_nodes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_parent_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":289
 *             self._populate_parents(node, parent_keys)
 * 
 *     def _find_tails(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_7_find_tails(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_7_find_tails(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_tails (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_find_tails(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_find_tails(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_tails = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_find_tails", 0);

  /* "breezy/_known_graph_pyx.pyx":294
 *         cdef Py_ssize_t pos
 * 
 *         tails = []             # <<<<<<<<<<<<<<
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tails = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":295
 * 
 *         tails = []
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 */
  __pyx_v_pos = 0;

  /* "breezy/_known_graph_pyx.pyx":296
 *         tails = []
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 */
  while (1) {
    __pyx_t_1 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = (PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node)) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":297
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 *                 node.gdfo = 1
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":298
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:             # <<<<<<<<<<<<<<
 *                 node.gdfo = 1
 *                 PyList_Append(tails, node)
 */
    __pyx_t_3 = (__pyx_v_node->parents == Py_None);
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = __pyx_v_node->parents;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = ((PyTuple_GET_SIZE(__pyx_t_1) == 0) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __pyx_t_4;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":299
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 *                 node.gdfo = 1             # <<<<<<<<<<<<<<
 *                 PyList_Append(tails, node)
 *         return tails
 */
      __pyx_v_node->gdfo = 1;

      /* "breezy/_known_graph_pyx.pyx":300
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 *                 node.gdfo = 1
 *                 PyList_Append(tails, node)             # <<<<<<<<<<<<<<
 *         return tails
 * 
 */
      __pyx_t_5 = PyList_Append(__pyx_v_tails, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 300, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":298
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:             # <<<<<<<<<<<<<<
 *                 node.gdfo = 1
 *                 PyList_Append(tails, node)
 */
    }
  }

  /* "breezy/_known_graph_pyx.pyx":301
 *                 node.gdfo = 1
 *                 PyList_Append(tails, node)
 *         return tails             # <<<<<<<<<<<<<<
 * 
 *     def _find_tips(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_tails);
  __pyx_r = __pyx_v_tails;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":289
 *             self._populate_parents(node, parent_keys)
 * 
 *     def _find_tails(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._find_tails", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_tails);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":303
 *         return tails
 * 
 *     def _find_tips(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_9_find_tips(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_9_find_tips(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_tips (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8_find_tips(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8_find_tips(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_tips = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_find_tips", 0);

  /* "breezy/_known_graph_pyx.pyx":308
 *         cdef Py_ssize_t pos
 * 
 *         tips = []             # <<<<<<<<<<<<<<
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tips = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":309
 * 
 *         tips = []
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 */
  __pyx_v_pos = 0;

  /* "breezy/_known_graph_pyx.pyx":310
 *         tips = []
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>temp_node
 *             if PyList_GET_SIZE(node.children) == 0:
 */
  while (1) {
    __pyx_t_1 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = (PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node)) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":311
 *         pos = 0
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *             if PyList_GET_SIZE(node.children) == 0:
 *                 PyList_Append(tips, node)
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":312
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if PyList_GET_SIZE(node.children) == 0:             # <<<<<<<<<<<<<<
 *                 PyList_Append(tips, node)
 *         return tips
 */
    __pyx_t_1 = __pyx_v_node->children;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = ((PyList_GET_SIZE(__pyx_t_1) == 0) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":313
 *             node = <_KnownGraphNode>temp_node
 *             if PyList_GET_SIZE(node.children) == 0:
 *                 PyList_Append(tips, node)             # <<<<<<<<<<<<<<
 *         return tips
 * 
 */
      __pyx_t_3 = PyList_Append(__pyx_v_tips, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 313, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":312
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if PyList_GET_SIZE(node.children) == 0:             # <<<<<<<<<<<<<<
 *                 PyList_Append(tips, node)
 *         return tips
 */
    }
  }

  /* "breezy/_known_graph_pyx.pyx":314
 *             if PyList_GET_SIZE(node.children) == 0:
 *                 PyList_Append(tips, node)
 *         return tips             # <<<<<<<<<<<<<<
 * 
 *     def _find_gdfo(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_tips);
  __pyx_r = __pyx_v_tips;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":303
 *         return tails
 * 
 *     def _find_tips(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _KnownGraphNode node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._find_tips", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_tips);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":316
 *         return tips
 * 
 *     def _find_gdfo(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 *         cdef _KnownGraphNode child
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_11_find_gdfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_11_find_gdfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_gdfo (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_10_find_gdfo(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_10_find_gdfo(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_child = 0;
  Py_ssize_t __pyx_v_pos;
  Py_ssize_t __pyx_v_last_item;
  long __pyx_v_next_gdfo;
  PyObject *__pyx_v_pending = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_find_gdfo", 0);

  /* "breezy/_known_graph_pyx.pyx":325
 *         cdef long next_gdfo
 * 
 *         pending = self._find_tails()             # <<<<<<<<<<<<<<
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_tails); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pending = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":327
 *         pending = self._find_tails()
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 *         while last_item >= 0:
 *             # Avoid pop followed by push, instead, peek, and replace
 */
  __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);

  /* "breezy/_known_graph_pyx.pyx":328
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 *             # Avoid pop followed by push, instead, peek, and replace
 *             # timing shows this is 930ms => 770ms for OOo
 */
  while (1) {
    __pyx_t_4 = ((__pyx_v_last_item >= 0) != 0);
    if (!__pyx_t_4) break;

    /* "breezy/_known_graph_pyx.pyx":331
 *             # Avoid pop followed by push, instead, peek, and replace
 *             # timing shows this is 930ms => 770ms for OOo
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 *             last_item = last_item - 1
 *             next_gdfo = node.gdfo + 1
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":332
 *             # timing shows this is 930ms => 770ms for OOo
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 *             next_gdfo = node.gdfo + 1
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 */
    __pyx_v_last_item = (__pyx_v_last_item - 1);

    /* "breezy/_known_graph_pyx.pyx":333
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 *             next_gdfo = node.gdfo + 1             # <<<<<<<<<<<<<<
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 */
    __pyx_v_next_gdfo = (__pyx_v_node->gdfo + 1);

    /* "breezy/_known_graph_pyx.pyx":334
 *             last_item = last_item - 1
 *             next_gdfo = node.gdfo + 1
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):             # <<<<<<<<<<<<<<
 *                 child = _get_list_node(node.children, pos)
 *                 if next_gdfo > child.gdfo:
 */
    __pyx_t_1 = __pyx_v_node->children;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = PyList_GET_SIZE(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_5; __pyx_v_pos++) {

      /* "breezy/_known_graph_pyx.pyx":335
 *             next_gdfo = node.gdfo + 1
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)             # <<<<<<<<<<<<<<
 *                 if next_gdfo > child.gdfo:
 *                     child.gdfo = next_gdfo
 */
      __pyx_t_1 = __pyx_v_node->children;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_2 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_pos)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_child, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "breezy/_known_graph_pyx.pyx":336
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 *                 if next_gdfo > child.gdfo:             # <<<<<<<<<<<<<<
 *                     child.gdfo = next_gdfo
 *                 child.seen = child.seen + 1
 */
      __pyx_t_4 = ((__pyx_v_next_gdfo > __pyx_v_child->gdfo) != 0);
      if (__pyx_t_4) {

        /* "breezy/_known_graph_pyx.pyx":337
 *                 child = _get_list_node(node.children, pos)
 *                 if next_gdfo > child.gdfo:
 *                     child.gdfo = next_gdfo             # <<<<<<<<<<<<<<
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 */
        __pyx_v_child->gdfo = __pyx_v_next_gdfo;

        /* "breezy/_known_graph_pyx.pyx":336
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 *                 if next_gdfo > child.gdfo:             # <<<<<<<<<<<<<<
 *                     child.gdfo = next_gdfo
 *                 child.seen = child.seen + 1
 */
      }

      /* "breezy/_known_graph_pyx.pyx":338
 *                 if next_gdfo > child.gdfo:
 *                     child.gdfo = next_gdfo
 *                 child.seen = child.seen + 1             # <<<<<<<<<<<<<<
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 *                     # This child is populated, queue it to be walked
 */
      __pyx_v_child->seen = (__pyx_v_child->seen + 1);

      /* "breezy/_known_graph_pyx.pyx":339
 *                     child.gdfo = next_gdfo
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 *                     # This child is populated, queue it to be walked
 *                     last_item = last_item + 1
 */
      __pyx_t_2 = __pyx_v_child->parents;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_4 = ((__pyx_v_child->seen == PyTuple_GET_SIZE(__pyx_t_2)) != 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_4) {

        /* "breezy/_known_graph_pyx.pyx":341
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 *                     # This child is populated, queue it to be walked
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref
 */
        __pyx_v_last_item = (__pyx_v_last_item + 1);

        /* "breezy/_known_graph_pyx.pyx":342
 *                     # This child is populated, queue it to be walked
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)
 */
        __pyx_t_4 = ((__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending)) != 0);
        if (__pyx_t_4) {

          /* "breezy/_known_graph_pyx.pyx":343
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref             # <<<<<<<<<<<<<<
 *                         PyList_SetItem(pending, last_item, child)
 *                     else:
 */
          Py_INCREF(((PyObject *)__pyx_v_child));

          /* "breezy/_known_graph_pyx.pyx":344
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)             # <<<<<<<<<<<<<<
 *                     else:
 *                         PyList_Append(pending, child)
 */
          __pyx_t_6 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 344, __pyx_L1_error)

          /* "breezy/_known_graph_pyx.pyx":342
 *                     # This child is populated, queue it to be walked
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)
 */
          goto __pyx_L9;
        }

        /* "breezy/_known_graph_pyx.pyx":346
 *                         PyList_SetItem(pending, last_item, child)
 *                     else:
 *                         PyList_Append(pending, child)             # <<<<<<<<<<<<<<
 *                     # We have queued this node, we don't need to track it
 *                     # anymore
 */
        /*else*/ {
          __pyx_t_6 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 346, __pyx_L1_error)
        }
        __pyx_L9:;

        /* "breezy/_known_graph_pyx.pyx":349
 *                     # We have queued this node, we don't need to track it
 *                     # anymore
 *                     child.seen = 0             # <<<<<<<<<<<<<<
 * 
 *     def add_node(self, key, parent_keys):
 */
        __pyx_v_child->seen = 0;

        /* "breezy/_known_graph_pyx.pyx":339
 *                     child.gdfo = next_gdfo
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 *                     # This child is populated, queue it to be walked
 *                     last_item = last_item + 1
 */
      }
    }
  }

  /* "breezy/_known_graph_pyx.pyx":316
 *         return tips
 * 
 *     def _find_gdfo(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 *         cdef _KnownGraphNode child
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph._find_gdfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_pending);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":351
 *                     child.seen = 0
 * 
 *     def add_node(self, key, parent_keys):             # <<<<<<<<<<<<<<
 *         """Add a new node to the graph.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_13add_node(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_12add_node[] = "Add a new node to the graph.\n\n        If this fills in a ghost, then the gdfos of all children will be\n        updated accordingly.\n\n        :param key: The node being added. If this is a duplicate, this is a\n            no-op.\n        :param parent_keys: The parents of the given node.\n        :return: None (should we return if this was a ghost, etc?)\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_13add_node(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_parent_keys = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_node (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_parent_keys,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parent_keys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_node", 1, 2, 2, 1); __PYX_ERR(0, 351, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_node") < 0)) __PYX_ERR(0, 351, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_key = values[0];
    __pyx_v_parent_keys = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_node", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 351, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.add_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12add_node(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_key, __pyx_v_parent_keys);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12add_node(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_parent_keys) {
  PyObject *__pyx_v_maybe_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_child_node = 0;
  long __pyx_v_parent_gdfo;
  long __pyx_v_next_gdfo;
  PyObject *__pyx_v_existing_parent_keys = NULL;
  PyObject *__pyx_v_pending = NULL;
  PyObject *__pyx_v_pending_popleft = NULL;
  PyObject *__pyx_v_pending_append = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("add_node", 0);
  __Pyx_INCREF(__pyx_v_parent_keys);

  /* "breezy/_known_graph_pyx.pyx":366
 *         cdef long parent_gdfo, next_gdfo
 * 
 *         maybe_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 *         if maybe_node != NULL:
 *             node = <_KnownGraphNode>maybe_node
 */
  __pyx_t_1 = __pyx_v_self->_nodes;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_maybe_node = PyDict_GetItem(__pyx_t_1, __pyx_v_key);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":367
 * 
 *         maybe_node = PyDict_GetItem(self._nodes, key)
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>maybe_node
 *             if node.parents is None:
 */
  __pyx_t_2 = ((__pyx_v_maybe_node != NULL) != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":368
 *         maybe_node = PyDict_GetItem(self._nodes, key)
 *         if maybe_node != NULL:
 *             node = <_KnownGraphNode>maybe_node             # <<<<<<<<<<<<<<
 *             if node.parents is None:
 *                 # We are filling in a ghost
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_maybe_node);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":369
 *         if maybe_node != NULL:
 *             node = <_KnownGraphNode>maybe_node
 *             if node.parents is None:             # <<<<<<<<<<<<<<
 *                 # We are filling in a ghost
 *                 self._populate_parents(node, parent_keys)
 */
    __pyx_t_2 = (__pyx_v_node->parents == Py_None);
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "breezy/_known_graph_pyx.pyx":371
 *             if node.parents is None:
 *                 # We are filling in a ghost
 *                 self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 *                 # We can't trust cached heads anymore
 *                 self._known_heads.clear()
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_populate_parents(__pyx_v_self, __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":373
 *                 self._populate_parents(node, parent_keys)
 *                 # We can't trust cached heads anymore
 *                 self._known_heads.clear()             # <<<<<<<<<<<<<<
 *             else: # Ensure that the parent_key list matches
 *                 existing_parent_keys = []
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_known_heads, __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":369
 *         if maybe_node != NULL:
 *             node = <_KnownGraphNode>maybe_node
 *             if node.parents is None:             # <<<<<<<<<<<<<<
 *                 # We are filling in a ghost
 *                 self._populate_parents(node, parent_keys)
 */
      goto __pyx_L4;
    }

    /* "breezy/_known_graph_pyx.pyx":375
 *                 self._known_heads.clear()
 *             else: # Ensure that the parent_key list matches
 *                 existing_parent_keys = []             # <<<<<<<<<<<<<<
 *                 for parent_node in node.parents:
 *                     existing_parent_keys.append(parent_node.key)
 */
    /*else*/ {
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_existing_parent_keys = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":376
 *             else: # Ensure that the parent_key list matches
 *                 existing_parent_keys = []
 *                 for parent_node in node.parents:             # <<<<<<<<<<<<<<
 *                     existing_parent_keys.append(parent_node.key)
 *                 # Make sure we use a list for the comparison, in case it was a
 */
      if (likely(PyList_CheckExact(__pyx_v_node->parents)) || PyTuple_CheckExact(__pyx_v_node->parents)) {
        __pyx_t_1 = __pyx_v_node->parents; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_node->parents); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 376, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_7)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 376, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          } else {
            if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 376, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          }
        } else {
          __pyx_t_4 = __pyx_t_7(__pyx_t_1);
          if (unlikely(!__pyx_t_4)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 376, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_4);
        }
        if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4));
        __pyx_t_4 = 0;

        /* "breezy/_known_graph_pyx.pyx":377
 *                 existing_parent_keys = []
 *                 for parent_node in node.parents:
 *                     existing_parent_keys.append(parent_node.key)             # <<<<<<<<<<<<<<
 *                 # Make sure we use a list for the comparison, in case it was a
 *                 # tuple, etc
 */
        __pyx_t_4 = __pyx_v_parent_node->key;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_existing_parent_keys, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "breezy/_known_graph_pyx.pyx":376
 *             else: # Ensure that the parent_key list matches
 *                 existing_parent_keys = []
 *                 for parent_node in node.parents:             # <<<<<<<<<<<<<<
 *                     existing_parent_keys.append(parent_node.key)
 *                 # Make sure we use a list for the comparison, in case it was a
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":380
 *                 # Make sure we use a list for the comparison, in case it was a
 *                 # tuple, etc
 *                 parent_keys = list(parent_keys)             # <<<<<<<<<<<<<<
 *                 if existing_parent_keys == parent_keys:
 *                     # Exact match, nothing more to do
 */
      __pyx_t_1 = PySequence_List(__pyx_v_parent_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_parent_keys, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":381
 *                 # tuple, etc
 *                 parent_keys = list(parent_keys)
 *                 if existing_parent_keys == parent_keys:             # <<<<<<<<<<<<<<
 *                     # Exact match, nothing more to do
 *                     return
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_existing_parent_keys, __pyx_v_parent_keys, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(__pyx_t_3)) {

        /* "breezy/_known_graph_pyx.pyx":383
 *                 if existing_parent_keys == parent_keys:
 *                     # Exact match, nothing more to do
 *                     return             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError('Parent key mismatch, existing node %s'
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L0;

        /* "breezy/_known_graph_pyx.pyx":381
 *                 # tuple, etc
 *                 parent_keys = list(parent_keys)
 *                 if existing_parent_keys == parent_keys:             # <<<<<<<<<<<<<<
 *                     # Exact match, nothing more to do
 *                     return
 */
      }

      /* "breezy/_known_graph_pyx.pyx":385
 *                     return
 *                 else:
 *                     raise ValueError('Parent key mismatch, existing node %s'             # <<<<<<<<<<<<<<
 *                         ' has parents of %s not %s'
 *                         % (key, existing_parent_keys, parent_keys))
 */
      /*else*/ {

        /* "breezy/_known_graph_pyx.pyx":387
 *                     raise ValueError('Parent key mismatch, existing node %s'
 *                         ' has parents of %s not %s'
 *                         % (key, existing_parent_keys, parent_keys))             # <<<<<<<<<<<<<<
 *         else:
 *             node = _KnownGraphNode(key)
 */
        __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
        __Pyx_INCREF(__pyx_v_existing_parent_keys);
        __Pyx_GIVEREF(__pyx_v_existing_parent_keys);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_existing_parent_keys);
        __Pyx_INCREF(__pyx_v_parent_keys);
        __Pyx_GIVEREF(__pyx_v_parent_keys);
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_parent_keys);
        __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Parent_key_mismatch_existing_nod, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "breezy/_known_graph_pyx.pyx":385
 *                     return
 *                 else:
 *                     raise ValueError('Parent key mismatch, existing node %s'             # <<<<<<<<<<<<<<
 *                         ' has parents of %s not %s'
 *                         % (key, existing_parent_keys, parent_keys))
 */
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 385, __pyx_L1_error)
      }
    }
    __pyx_L4:;

    /* "breezy/_known_graph_pyx.pyx":367
 * 
 *         maybe_node = PyDict_GetItem(self._nodes, key)
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>maybe_node
 *             if node.parents is None:
 */
    goto __pyx_L3;
  }

  /* "breezy/_known_graph_pyx.pyx":389
 *                         % (key, existing_parent_keys, parent_keys))
 *         else:
 *             node = _KnownGraphNode(key)             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(self._nodes, key, node)
 *             self._populate_parents(node, parent_keys)
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode), __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":390
 *         else:
 *             node = _KnownGraphNode(key)
 *             PyDict_SetItem(self._nodes, key, node)             # <<<<<<<<<<<<<<
 *             self._populate_parents(node, parent_keys)
 *         parent_gdfo = 0
 */
    __pyx_t_1 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_9 = PyDict_SetItem(__pyx_t_1, __pyx_v_key, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":391
 *             node = _KnownGraphNode(key)
 *             PyDict_SetItem(self._nodes, key, node)
 *             self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 *         parent_gdfo = 0
 *         for parent_node in node.parents:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_populate_parents(__pyx_v_self, __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "breezy/_known_graph_pyx.pyx":392
 *             PyDict_SetItem(self._nodes, key, node)
 *             self._populate_parents(node, parent_keys)
 *         parent_gdfo = 0             # <<<<<<<<<<<<<<
 *         for parent_node in node.parents:
 *             if parent_node.gdfo == -1:
 */
  __pyx_v_parent_gdfo = 0;

  /* "breezy/_known_graph_pyx.pyx":393
 *             self._populate_parents(node, parent_keys)
 *         parent_gdfo = 0
 *         for parent_node in node.parents:             # <<<<<<<<<<<<<<
 *             if parent_node.gdfo == -1:
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 */
  if (likely(PyList_CheckExact(__pyx_v_node->parents)) || PyTuple_CheckExact(__pyx_v_node->parents)) {
    __pyx_t_1 = __pyx_v_node->parents; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_node->parents); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 393, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 393, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 393, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 393, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":394
 *         parent_gdfo = 0
 *         for parent_node in node.parents:
 *             if parent_node.gdfo == -1:             # <<<<<<<<<<<<<<
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 *                 parent_node.gdfo = 1
 */
    __pyx_t_3 = ((__pyx_v_parent_node->gdfo == -1L) != 0);
    if (__pyx_t_3) {

      /* "breezy/_known_graph_pyx.pyx":396
 *             if parent_node.gdfo == -1:
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 *                 parent_node.gdfo = 1             # <<<<<<<<<<<<<<
 *             if parent_gdfo < parent_node.gdfo:
 *                 parent_gdfo = parent_node.gdfo
 */
      __pyx_v_parent_node->gdfo = 1;

      /* "breezy/_known_graph_pyx.pyx":394
 *         parent_gdfo = 0
 *         for parent_node in node.parents:
 *             if parent_node.gdfo == -1:             # <<<<<<<<<<<<<<
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 *                 parent_node.gdfo = 1
 */
    }

    /* "breezy/_known_graph_pyx.pyx":397
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 *                 parent_node.gdfo = 1
 *             if parent_gdfo < parent_node.gdfo:             # <<<<<<<<<<<<<<
 *                 parent_gdfo = parent_node.gdfo
 *         node.gdfo = parent_gdfo + 1
 */
    __pyx_t_3 = ((__pyx_v_parent_gdfo < __pyx_v_parent_node->gdfo) != 0);
    if (__pyx_t_3) {

      /* "breezy/_known_graph_pyx.pyx":398
 *                 parent_node.gdfo = 1
 *             if parent_gdfo < parent_node.gdfo:
 *                 parent_gdfo = parent_node.gdfo             # <<<<<<<<<<<<<<
 *         node.gdfo = parent_gdfo + 1
 *         # Now fill the gdfo to all children
 */
      __pyx_t_10 = __pyx_v_parent_node->gdfo;
      __pyx_v_parent_gdfo = __pyx_t_10;

      /* "breezy/_known_graph_pyx.pyx":397
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 *                 parent_node.gdfo = 1
 *             if parent_gdfo < parent_node.gdfo:             # <<<<<<<<<<<<<<
 *                 parent_gdfo = parent_node.gdfo
 *         node.gdfo = parent_gdfo + 1
 */
    }

    /* "breezy/_known_graph_pyx.pyx":393
 *             self._populate_parents(node, parent_keys)
 *         parent_gdfo = 0
 *         for parent_node in node.parents:             # <<<<<<<<<<<<<<
 *             if parent_node.gdfo == -1:
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":399
 *             if parent_gdfo < parent_node.gdfo:
 *                 parent_gdfo = parent_node.gdfo
 *         node.gdfo = parent_gdfo + 1             # <<<<<<<<<<<<<<
 *         # Now fill the gdfo to all children
 *         # Note that this loop is slightly inefficient, in that we may visit the
 */
  __pyx_v_node->gdfo = (__pyx_v_parent_gdfo + 1);

  /* "breezy/_known_graph_pyx.pyx":408
 *         # than DFD. So that if a longer path is possible, we walk it before we
 *         # get to the final child
 *         pending = collections.deque([node])             # <<<<<<<<<<<<<<
 *         pending_popleft = pending.popleft
 *         pending_append = pending.append
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_collections); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deque); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_node));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_node));
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_pending = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":409
 *         # get to the final child
 *         pending = collections.deque([node])
 *         pending_popleft = pending.popleft             # <<<<<<<<<<<<<<
 *         pending_append = pending.append
 *         while pending:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pending, __pyx_n_s_popleft); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_pending_popleft = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":410
 *         pending = collections.deque([node])
 *         pending_popleft = pending.popleft
 *         pending_append = pending.append             # <<<<<<<<<<<<<<
 *         while pending:
 *             node = pending_popleft()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pending, __pyx_n_s_append); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_pending_append = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":411
 *         pending_popleft = pending.popleft
 *         pending_append = pending.append
 *         while pending:             # <<<<<<<<<<<<<<
 *             node = pending_popleft()
 *             next_gdfo = node.gdfo + 1
 */
  while (1) {
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_pending); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 411, __pyx_L1_error)
    if (!__pyx_t_3) break;

    /* "breezy/_known_graph_pyx.pyx":412
 *         pending_append = pending.append
 *         while pending:
 *             node = pending_popleft()             # <<<<<<<<<<<<<<
 *             next_gdfo = node.gdfo + 1
 *             for child_node in node.children:
 */
    __Pyx_INCREF(__pyx_v_pending_popleft);
    __pyx_t_5 = __pyx_v_pending_popleft; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":413
 *         while pending:
 *             node = pending_popleft()
 *             next_gdfo = node.gdfo + 1             # <<<<<<<<<<<<<<
 *             for child_node in node.children:
 *                 if child_node.gdfo < next_gdfo:
 */
    __pyx_v_next_gdfo = (__pyx_v_node->gdfo + 1);

    /* "breezy/_known_graph_pyx.pyx":414
 *             node = pending_popleft()
 *             next_gdfo = node.gdfo + 1
 *             for child_node in node.children:             # <<<<<<<<<<<<<<
 *                 if child_node.gdfo < next_gdfo:
 *                     # This child is being updated, we need to check its
 */
    if (likely(PyList_CheckExact(__pyx_v_node->children)) || PyTuple_CheckExact(__pyx_v_node->children)) {
      __pyx_t_1 = __pyx_v_node->children; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_node->children); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 414, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 414, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 414, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_7(__pyx_t_1);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 414, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_child_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "breezy/_known_graph_pyx.pyx":415
 *             next_gdfo = node.gdfo + 1
 *             for child_node in node.children:
 *                 if child_node.gdfo < next_gdfo:             # <<<<<<<<<<<<<<
 *                     # This child is being updated, we need to check its
 *                     # children
 */
      __pyx_t_3 = ((__pyx_v_child_node->gdfo < __pyx_v_next_gdfo) != 0);
      if (__pyx_t_3) {

        /* "breezy/_known_graph_pyx.pyx":418
 *                     # This child is being updated, we need to check its
 *                     # children
 *                     child_node.gdfo = next_gdfo             # <<<<<<<<<<<<<<
 *                     pending_append(child_node)
 * 
 */
        __pyx_v_child_node->gdfo = __pyx_v_next_gdfo;

        /* "breezy/_known_graph_pyx.pyx":419
 *                     # children
 *                     child_node.gdfo = next_gdfo
 *                     pending_append(child_node)             # <<<<<<<<<<<<<<
 * 
 *     def heads(self, keys):
 */
        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_pending, ((PyObject *)__pyx_v_child_node)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 419, __pyx_L1_error)

        /* "breezy/_known_graph_pyx.pyx":415
 *             next_gdfo = node.gdfo + 1
 *             for child_node in node.children:
 *                 if child_node.gdfo < next_gdfo:             # <<<<<<<<<<<<<<
 *                     # This child is being updated, we need to check its
 *                     # children
 */
      }

      /* "breezy/_known_graph_pyx.pyx":414
 *             node = pending_popleft()
 *             next_gdfo = node.gdfo + 1
 *             for child_node in node.children:             # <<<<<<<<<<<<<<
 *                 if child_node.gdfo < next_gdfo:
 *                     # This child is being updated, we need to check its
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "breezy/_known_graph_pyx.pyx":351
 *                     child.seen = 0
 * 
 *     def add_node(self, key, parent_keys):             # <<<<<<<<<<<<<<
 *         """Add a new node to the graph.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.add_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_child_node);
  __Pyx_XDECREF(__pyx_v_existing_parent_keys);
  __Pyx_XDECREF(__pyx_v_pending);
  __Pyx_XDECREF(__pyx_v_pending_popleft);
  __Pyx_XDECREF(__pyx_v_pending_append);
  __Pyx_XDECREF(__pyx_v_parent_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":421
 *                     pending_append(child_node)
 * 
 *     def heads(self, keys):             # <<<<<<<<<<<<<<
 *         """Return the heads from amongst keys.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_15heads(PyObject *__pyx_v_self, PyObject *__pyx_v_keys); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_14heads[] = "Return the heads from amongst keys.\n\n        This is done by searching the ancestries of each key.  Any key that is\n        reachable from another key is not returned; all the others are.\n\n        This operation scales with the relative depth between any two keys. It\n        uses gdfo to avoid walking all ancestry.\n\n        :param keys: An iterable of keys.\n        :return: A set of the heads. Note that as a set there is no ordering\n            information. Callers will need to filter their input to create\n            order if they need it.\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_15heads(PyObject *__pyx_v_self, PyObject *__pyx_v_keys) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("heads (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_14heads(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_keys));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_14heads(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_keys) {
  PyObject *__pyx_v_maybe_node;
  PyObject *__pyx_v_maybe_heads;
  PyObject *__pyx_v_temp_node;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  Py_ssize_t __pyx_v_pos;
  Py_ssize_t __pyx_v_last_item;
  long __pyx_v_min_gdfo;
  PyObject *__pyx_v_heads_key = NULL;
  PyObject *__pyx_v_candidate_nodes = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_cleanup = NULL;
  PyObject *__pyx_v_pending = NULL;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node = NULL;
  PyObject *__pyx_v_heads = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("heads", 0);

  /* "breezy/_known_graph_pyx.pyx":442
 *         cdef long min_gdfo
 * 
 *         heads_key = frozenset(keys)             # <<<<<<<<<<<<<<
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 *         if maybe_heads != NULL:
 */
  __pyx_t_1 = __Pyx_PyFrozenSet_New(__pyx_v_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_heads_key = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":443
 * 
 *         heads_key = frozenset(keys)
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)             # <<<<<<<<<<<<<<
 *         if maybe_heads != NULL:
 *             return <object>maybe_heads
 */
  __pyx_t_1 = __pyx_v_self->_known_heads;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_maybe_heads = PyDict_GetItem(__pyx_t_1, __pyx_v_heads_key);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":444
 *         heads_key = frozenset(keys)
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 *         if maybe_heads != NULL:             # <<<<<<<<<<<<<<
 *             return <object>maybe_heads
 *         # Not cached, compute it ourselves
 */
  __pyx_t_2 = ((__pyx_v_maybe_heads != NULL) != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":445
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 *         if maybe_heads != NULL:
 *             return <object>maybe_heads             # <<<<<<<<<<<<<<
 *         # Not cached, compute it ourselves
 *         candidate_nodes = {}
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_maybe_heads));
    __pyx_r = ((PyObject *)__pyx_v_maybe_heads);
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":444
 *         heads_key = frozenset(keys)
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 *         if maybe_heads != NULL:             # <<<<<<<<<<<<<<
 *             return <object>maybe_heads
 *         # Not cached, compute it ourselves
 */
  }

  /* "breezy/_known_graph_pyx.pyx":447
 *             return <object>maybe_heads
 *         # Not cached, compute it ourselves
 *         candidate_nodes = {}             # <<<<<<<<<<<<<<
 *         for key in keys:
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_candidate_nodes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":448
 *         # Not cached, compute it ourselves
 *         candidate_nodes = {}
 *         for key in keys:             # <<<<<<<<<<<<<<
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 *             if maybe_node == NULL:
 */
  if (likely(PyList_CheckExact(__pyx_v_keys)) || PyTuple_CheckExact(__pyx_v_keys)) {
    __pyx_t_1 = __pyx_v_keys; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 448, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 448, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 448, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 448, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 448, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 448, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":449
 *         candidate_nodes = {}
 *         for key in keys:
 *             maybe_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 *             if maybe_node == NULL:
 *                 raise KeyError('key %s not in nodes' % (key,))
 */
    __pyx_t_5 = __pyx_v_self->_nodes;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_v_maybe_node = PyDict_GetItem(__pyx_t_5, __pyx_v_key);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":450
 *         for key in keys:
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 *             if maybe_node == NULL:             # <<<<<<<<<<<<<<
 *                 raise KeyError('key %s not in nodes' % (key,))
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 */
    __pyx_t_2 = ((__pyx_v_maybe_node == NULL) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "breezy/_known_graph_pyx.pyx":451
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 *             if maybe_node == NULL:
 *                 raise KeyError('key %s not in nodes' % (key,))             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_key);
      __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_key_s_not_in_nodes, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 451, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":450
 *         for key in keys:
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 *             if maybe_node == NULL:             # <<<<<<<<<<<<<<
 *                 raise KeyError('key %s not in nodes' % (key,))
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 */
    }

    /* "breezy/_known_graph_pyx.pyx":452
 *             if maybe_node == NULL:
 *                 raise KeyError('key %s not in nodes' % (key,))
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)             # <<<<<<<<<<<<<<
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 *         if maybe_node != NULL:
 */
    __pyx_t_7 = PyDict_SetItem(__pyx_v_candidate_nodes, __pyx_v_key, ((PyObject *)__pyx_v_maybe_node)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 452, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":448
 *         # Not cached, compute it ourselves
 *         candidate_nodes = {}
 *         for key in keys:             # <<<<<<<<<<<<<<
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 *             if maybe_node == NULL:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":453
 *                 raise KeyError('key %s not in nodes' % (key,))
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)             # <<<<<<<<<<<<<<
 *         if maybe_node != NULL:
 *             # NULL_REVISION is only a head if it is the only entry
 */
  __pyx_t_1 = __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_maybe_node = PyDict_GetItem(__pyx_v_candidate_nodes, __pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":454
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 *             # NULL_REVISION is only a head if it is the only entry
 *             candidate_nodes.pop(NULL_REVISION)
 */
  __pyx_t_2 = ((__pyx_v_maybe_node != NULL) != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":456
 *         if maybe_node != NULL:
 *             # NULL_REVISION is only a head if it is the only entry
 *             candidate_nodes.pop(NULL_REVISION)             # <<<<<<<<<<<<<<
 *             if not candidate_nodes:
 *                 return frozenset([NULL_REVISION])
 */
    __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_candidate_nodes, __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION, ((PyObject *)NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":457
 *             # NULL_REVISION is only a head if it is the only entry
 *             candidate_nodes.pop(NULL_REVISION)
 *             if not candidate_nodes:             # <<<<<<<<<<<<<<
 *                 return frozenset([NULL_REVISION])
 *             # The keys changed, so recalculate heads_key
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_candidate_nodes); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
    __pyx_t_8 = ((!__pyx_t_2) != 0);
    if (__pyx_t_8) {

      /* "breezy/_known_graph_pyx.pyx":458
 *             candidate_nodes.pop(NULL_REVISION)
 *             if not candidate_nodes:
 *                 return frozenset([NULL_REVISION])             # <<<<<<<<<<<<<<
 *             # The keys changed, so recalculate heads_key
 *             heads_key = frozenset(candidate_nodes)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
      __Pyx_GIVEREF(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
      __pyx_t_5 = __Pyx_PyFrozenSet_New(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L0;

      /* "breezy/_known_graph_pyx.pyx":457
 *             # NULL_REVISION is only a head if it is the only entry
 *             candidate_nodes.pop(NULL_REVISION)
 *             if not candidate_nodes:             # <<<<<<<<<<<<<<
 *                 return frozenset([NULL_REVISION])
 *             # The keys changed, so recalculate heads_key
 */
    }

    /* "breezy/_known_graph_pyx.pyx":460
 *                 return frozenset([NULL_REVISION])
 *             # The keys changed, so recalculate heads_key
 *             heads_key = frozenset(candidate_nodes)             # <<<<<<<<<<<<<<
 *         if PyDict_Size(candidate_nodes) < 2:
 *             return heads_key
 */
    __pyx_t_5 = __Pyx_PyFrozenSet_New(__pyx_v_candidate_nodes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_heads_key, ((PyObject*)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":454
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 *             # NULL_REVISION is only a head if it is the only entry
 *             candidate_nodes.pop(NULL_REVISION)
 */
  }

  /* "breezy/_known_graph_pyx.pyx":461
 *             # The keys changed, so recalculate heads_key
 *             heads_key = frozenset(candidate_nodes)
 *         if PyDict_Size(candidate_nodes) < 2:             # <<<<<<<<<<<<<<
 *             return heads_key
 * 
 */
  __pyx_t_3 = PyDict_Size(__pyx_v_candidate_nodes); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 461, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_3 < 2) != 0);
  if (__pyx_t_8) {

    /* "breezy/_known_graph_pyx.pyx":462
 *             heads_key = frozenset(candidate_nodes)
 *         if PyDict_Size(candidate_nodes) < 2:
 *             return heads_key             # <<<<<<<<<<<<<<
 * 
 *         cleanup = []
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_heads_key);
    __pyx_r = __pyx_v_heads_key;
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":461
 *             # The keys changed, so recalculate heads_key
 *             heads_key = frozenset(candidate_nodes)
 *         if PyDict_Size(candidate_nodes) < 2:             # <<<<<<<<<<<<<<
 *             return heads_key
 * 
 */
  }

  /* "breezy/_known_graph_pyx.pyx":464
 *             return heads_key
 * 
 *         cleanup = []             # <<<<<<<<<<<<<<
 *         pending = []
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_cleanup = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "breezy/_known_graph_pyx.pyx":465
 * 
 *         cleanup = []
 *         pending = []             # <<<<<<<<<<<<<<
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 *         min_gdfo = PyDict_Size(self._nodes) + 1
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_pending = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "breezy/_known_graph_pyx.pyx":467
 *         pending = []
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 *         min_gdfo = PyDict_Size(self._nodes) + 1             # <<<<<<<<<<<<<<
 *         # Build up nodes that need to be walked, note that starting nodes are
 *         # not added to seen()
 */
  __pyx_t_5 = __pyx_v_self->_nodes;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_3 = PyDict_Size(__pyx_t_5); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 467, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_min_gdfo = (__pyx_t_3 + 1);

  /* "breezy/_known_graph_pyx.pyx":470
 *         # Build up nodes that need to be walked, note that starting nodes are
 *         # not added to seen()
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 */
  __pyx_v_pos = 0;

  /* "breezy/_known_graph_pyx.pyx":471
 *         # not added to seen()
 *         pos = 0
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is not None:
 */
  while (1) {
    __pyx_t_8 = (PyDict_Next(__pyx_v_candidate_nodes, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node)) != 0);
    if (!__pyx_t_8) break;

    /* "breezy/_known_graph_pyx.pyx":472
 *         pos = 0
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *             if node.parents is not None:
 *                 pending.extend(node.parents)
 */
    __pyx_t_5 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":473
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 *                 pending.extend(node.parents)
 *             if node.gdfo < min_gdfo:
 */
    __pyx_t_8 = (__pyx_v_node->parents != Py_None);
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":474
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is not None:
 *                 pending.extend(node.parents)             # <<<<<<<<<<<<<<
 *             if node.gdfo < min_gdfo:
 *                 min_gdfo = node.gdfo
 */
      __pyx_t_5 = __pyx_v_node->parents;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_pending, __pyx_t_5); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "breezy/_known_graph_pyx.pyx":473
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 *                 pending.extend(node.parents)
 *             if node.gdfo < min_gdfo:
 */
    }

    /* "breezy/_known_graph_pyx.pyx":475
 *             if node.parents is not None:
 *                 pending.extend(node.parents)
 *             if node.gdfo < min_gdfo:             # <<<<<<<<<<<<<<
 *                 min_gdfo = node.gdfo
 * 
 */
    __pyx_t_2 = ((__pyx_v_node->gdfo < __pyx_v_min_gdfo) != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":476
 *                 pending.extend(node.parents)
 *             if node.gdfo < min_gdfo:
 *                 min_gdfo = node.gdfo             # <<<<<<<<<<<<<<
 * 
 *         # Now do all the real work
 */
      __pyx_t_10 = __pyx_v_node->gdfo;
      __pyx_v_min_gdfo = __pyx_t_10;

      /* "breezy/_known_graph_pyx.pyx":475
 *             if node.parents is not None:
 *                 pending.extend(node.parents)
 *             if node.gdfo < min_gdfo:             # <<<<<<<<<<<<<<
 *                 min_gdfo = node.gdfo
 * 
 */
    }
  }

  /* "breezy/_known_graph_pyx.pyx":479
 * 
 *         # Now do all the real work
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 *         while last_item >= 0:
 *             node = _get_list_node(pending, last_item)
 */
  __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);

  /* "breezy/_known_graph_pyx.pyx":480
 *         # Now do all the real work
 *         last_item = PyList_GET_SIZE(pending) - 1
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_last_item >= 0) != 0);
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":481
 *         last_item = PyList_GET_SIZE(pending) - 1
 *         while last_item >= 0:
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 *             last_item = last_item - 1
 *             if node.seen:
 */
    __pyx_t_5 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":482
 *         while last_item >= 0:
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 *             if node.seen:
 *                 # node already appears in some ancestry
 */
    __pyx_v_last_item = (__pyx_v_last_item - 1);

    /* "breezy/_known_graph_pyx.pyx":483
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 *             if node.seen:             # <<<<<<<<<<<<<<
 *                 # node already appears in some ancestry
 *                 continue
 */
    __pyx_t_2 = (__pyx_v_node->seen != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":485
 *             if node.seen:
 *                 # node already appears in some ancestry
 *                 continue             # <<<<<<<<<<<<<<
 *             PyList_Append(cleanup, node)
 *             node.seen = 1
 */
      goto __pyx_L14_continue;

      /* "breezy/_known_graph_pyx.pyx":483
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 *             if node.seen:             # <<<<<<<<<<<<<<
 *                 # node already appears in some ancestry
 *                 continue
 */
    }

    /* "breezy/_known_graph_pyx.pyx":486
 *                 # node already appears in some ancestry
 *                 continue
 *             PyList_Append(cleanup, node)             # <<<<<<<<<<<<<<
 *             node.seen = 1
 *             if node.gdfo <= min_gdfo:
 */
    __pyx_t_7 = PyList_Append(__pyx_v_cleanup, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 486, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":487
 *                 continue
 *             PyList_Append(cleanup, node)
 *             node.seen = 1             # <<<<<<<<<<<<<<
 *             if node.gdfo <= min_gdfo:
 *                 continue
 */
    __pyx_v_node->seen = 1;

    /* "breezy/_known_graph_pyx.pyx":488
 *             PyList_Append(cleanup, node)
 *             node.seen = 1
 *             if node.gdfo <= min_gdfo:             # <<<<<<<<<<<<<<
 *                 continue
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 */
    __pyx_t_2 = ((__pyx_v_node->gdfo <= __pyx_v_min_gdfo) != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":489
 *             node.seen = 1
 *             if node.gdfo <= min_gdfo:
 *                 continue             # <<<<<<<<<<<<<<
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 */
      goto __pyx_L14_continue;

      /* "breezy/_known_graph_pyx.pyx":488
 *             PyList_Append(cleanup, node)
 *             node.seen = 1
 *             if node.gdfo <= min_gdfo:             # <<<<<<<<<<<<<<
 *                 continue
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 */
    }

    /* "breezy/_known_graph_pyx.pyx":490
 *             if node.gdfo <= min_gdfo:
 *                 continue
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 *                     parent_node = _get_tuple_node(node.parents, pos)
 */
    __pyx_t_8 = (__pyx_v_node->parents != Py_None);
    __pyx_t_11 = (__pyx_t_8 != 0);
    if (__pyx_t_11) {
    } else {
      __pyx_t_2 = __pyx_t_11;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_5 = __pyx_v_node->parents;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_11 = ((PyTuple_GET_SIZE(__pyx_t_5) > 0) != 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __pyx_t_11;
    __pyx_L19_bool_binop_done:;
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":491
 *                 continue
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):             # <<<<<<<<<<<<<<
 *                     parent_node = _get_tuple_node(node.parents, pos)
 *                     last_item = last_item + 1
 */
      __pyx_t_5 = __pyx_v_node->parents;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_GET_SIZE(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_3; __pyx_v_pos++) {

        /* "breezy/_known_graph_pyx.pyx":492
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 *                     parent_node = _get_tuple_node(node.parents, pos)             # <<<<<<<<<<<<<<
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):
 */
        __pyx_t_5 = __pyx_v_node->parents;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_t_5, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 492, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
        __pyx_t_1 = 0;

        /* "breezy/_known_graph_pyx.pyx":493
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 *                     parent_node = _get_tuple_node(node.parents, pos)
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 */
        __pyx_v_last_item = (__pyx_v_last_item + 1);

        /* "breezy/_known_graph_pyx.pyx":494
 *                     parent_node = _get_tuple_node(node.parents, pos)
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, parent_node)
 */
        __pyx_t_2 = ((__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending)) != 0);
        if (__pyx_t_2) {

          /* "breezy/_known_graph_pyx.pyx":495
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(parent_node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 *                         PyList_SetItem(pending, last_item, parent_node)
 *                     else:
 */
          Py_INCREF(((PyObject *)__pyx_v_parent_node));

          /* "breezy/_known_graph_pyx.pyx":496
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, parent_node)             # <<<<<<<<<<<<<<
 *                     else:
 *                         PyList_Append(pending, parent_node)
 */
          __pyx_t_7 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 496, __pyx_L1_error)

          /* "breezy/_known_graph_pyx.pyx":494
 *                     parent_node = _get_tuple_node(node.parents, pos)
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, parent_node)
 */
          goto __pyx_L23;
        }

        /* "breezy/_known_graph_pyx.pyx":498
 *                         PyList_SetItem(pending, last_item, parent_node)
 *                     else:
 *                         PyList_Append(pending, parent_node)             # <<<<<<<<<<<<<<
 *         heads = []
 *         pos = 0
 */
        /*else*/ {
          __pyx_t_7 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 498, __pyx_L1_error)
        }
        __pyx_L23:;
      }

      /* "breezy/_known_graph_pyx.pyx":490
 *             if node.gdfo <= min_gdfo:
 *                 continue
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 *                     parent_node = _get_tuple_node(node.parents, pos)
 */
    }
    __pyx_L14_continue:;
  }

  /* "breezy/_known_graph_pyx.pyx":499
 *                     else:
 *                         PyList_Append(pending, parent_node)
 *         heads = []             # <<<<<<<<<<<<<<
 *         pos = 0
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_heads = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":500
 *                         PyList_Append(pending, parent_node)
 *         heads = []
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 */
  __pyx_v_pos = 0;

  /* "breezy/_known_graph_pyx.pyx":501
 *         heads = []
 *         pos = 0
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 *             node = <_KnownGraphNode>temp_node
 *             if not node.seen:
 */
  while (1) {
    __pyx_t_2 = (PyDict_Next(__pyx_v_candidate_nodes, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node)) != 0);
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":502
 *         pos = 0
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 *             if not node.seen:
 *                 PyList_Append(heads, node.key)
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_temp_node);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":503
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if not node.seen:             # <<<<<<<<<<<<<<
 *                 PyList_Append(heads, node.key)
 *         heads = frozenset(heads)
 */
    __pyx_t_2 = ((!(__pyx_v_node->seen != 0)) != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":504
 *             node = <_KnownGraphNode>temp_node
 *             if not node.seen:
 *                 PyList_Append(heads, node.key)             # <<<<<<<<<<<<<<
 *         heads = frozenset(heads)
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 */
      __pyx_t_1 = __pyx_v_node->key;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_7 = PyList_Append(__pyx_v_heads, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 504, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":503
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 *             node = <_KnownGraphNode>temp_node
 *             if not node.seen:             # <<<<<<<<<<<<<<
 *                 PyList_Append(heads, node.key)
 *         heads = frozenset(heads)
 */
    }
  }

  /* "breezy/_known_graph_pyx.pyx":505
 *             if not node.seen:
 *                 PyList_Append(heads, node.key)
 *         heads = frozenset(heads)             # <<<<<<<<<<<<<<
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 *             node = _get_list_node(cleanup, pos)
 */
  __pyx_t_1 = __Pyx_PyFrozenSet_New(__pyx_v_heads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_heads, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":506
 *                 PyList_Append(heads, node.key)
 *         heads = frozenset(heads)
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):             # <<<<<<<<<<<<<<
 *             node = _get_list_node(cleanup, pos)
 *             node.seen = 0
 */
  __pyx_t_3 = PyList_GET_SIZE(__pyx_v_cleanup);
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_3; __pyx_v_pos++) {

    /* "breezy/_known_graph_pyx.pyx":507
 *         heads = frozenset(heads)
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 *             node = _get_list_node(cleanup, pos)             # <<<<<<<<<<<<<<
 *             node.seen = 0
 *         if self.do_cache:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_cleanup, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":508
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 *             node = _get_list_node(cleanup, pos)
 *             node.seen = 0             # <<<<<<<<<<<<<<
 *         if self.do_cache:
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 */
    __pyx_v_node->seen = 0;
  }

  /* "breezy/_known_graph_pyx.pyx":509
 *             node = _get_list_node(cleanup, pos)
 *             node.seen = 0
 *         if self.do_cache:             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 *         return heads
 */
  __pyx_t_2 = (__pyx_v_self->do_cache != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":510
 *             node.seen = 0
 *         if self.do_cache:
 *             PyDict_SetItem(self._known_heads, heads_key, heads)             # <<<<<<<<<<<<<<
 *         return heads
 * 
 */
    __pyx_t_1 = __pyx_v_self->_known_heads;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7 = PyDict_SetItem(__pyx_t_1, __pyx_v_heads_key, __pyx_v_heads); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":509
 *             node = _get_list_node(cleanup, pos)
 *             node.seen = 0
 *         if self.do_cache:             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 *         return heads
 */
  }

  /* "breezy/_known_graph_pyx.pyx":511
 *         if self.do_cache:
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 *         return heads             # <<<<<<<<<<<<<<
 * 
 *     def topo_sort(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_heads);
  __pyx_r = __pyx_v_heads;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":421
 *                     pending_append(child_node)
 * 
 *     def heads(self, keys):             # <<<<<<<<<<<<<<
 *         """Return the heads from amongst keys.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.heads", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_heads_key);
  __Pyx_XDECREF(__pyx_v_candidate_nodes);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_cleanup);
  __Pyx_XDECREF(__pyx_v_pending);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_node);
  __Pyx_XDECREF(__pyx_v_heads);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":513
 *         return heads
 * 
 *     def topo_sort(self):             # <<<<<<<<<<<<<<
 *         """Return the nodes in topological order.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_17topo_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_16topo_sort[] = "Return the nodes in topological order.\n\n        All parents must occur before all children.\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_17topo_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("topo_sort (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_16topo_sort(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_16topo_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_child = 0;
  Py_ssize_t __pyx_v_pos;
  Py_ssize_t __pyx_v_last_item;
  PyObject *__pyx_v_pending = NULL;
  PyObject *__pyx_v_topo_order = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("topo_sort", 0);

  /* "breezy/_known_graph_pyx.pyx":530
 *         cdef Py_ssize_t last_item
 * 
 *         pending = self._find_tails()             # <<<<<<<<<<<<<<
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:
 *             raise errors.GraphCycleError(self._nodes)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_tails); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pending = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":531
 * 
 *         pending = self._find_tails()
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:             # <<<<<<<<<<<<<<
 *             raise errors.GraphCycleError(self._nodes)
 * 
 */
  __pyx_t_5 = ((PyList_GET_SIZE(__pyx_v_pending) == 0) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = __pyx_v_self->_nodes;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 531, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_6 > 0) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "breezy/_known_graph_pyx.pyx":532
 *         pending = self._find_tails()
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:
 *             raise errors.GraphCycleError(self._nodes)             # <<<<<<<<<<<<<<
 * 
 *         topo_order = []
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_GraphCycleError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_self->_nodes) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->_nodes);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 532, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":531
 * 
 *         pending = self._find_tails()
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:             # <<<<<<<<<<<<<<
 *             raise errors.GraphCycleError(self._nodes)
 * 
 */
  }

  /* "breezy/_known_graph_pyx.pyx":534
 *             raise errors.GraphCycleError(self._nodes)
 * 
 *         topo_order = []             # <<<<<<<<<<<<<<
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_topo_order = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":536
 *         topo_order = []
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 *         while last_item >= 0:
 *             # Avoid pop followed by push, instead, peek, and replace
 */
  __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);

  /* "breezy/_known_graph_pyx.pyx":537
 * 
 *         last_item = PyList_GET_SIZE(pending) - 1
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 *             # Avoid pop followed by push, instead, peek, and replace
 *             # timing shows this is 930ms => 770ms for OOo
 */
  while (1) {
    __pyx_t_4 = ((__pyx_v_last_item >= 0) != 0);
    if (!__pyx_t_4) break;

    /* "breezy/_known_graph_pyx.pyx":540
 *             # Avoid pop followed by push, instead, peek, and replace
 *             # timing shows this is 930ms => 770ms for OOo
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 *             last_item = last_item - 1
 *             if node.parents is not None:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":541
 *             # timing shows this is 930ms => 770ms for OOo
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 *             if node.parents is not None:
 *                 # We don't include ghost parents
 */
    __pyx_v_last_item = (__pyx_v_last_item - 1);

    /* "breezy/_known_graph_pyx.pyx":542
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 *                 # We don't include ghost parents
 *                 PyList_Append(topo_order, node.key)
 */
    __pyx_t_4 = (__pyx_v_node->parents != Py_None);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (__pyx_t_5) {

      /* "breezy/_known_graph_pyx.pyx":544
 *             if node.parents is not None:
 *                 # We don't include ghost parents
 *                 PyList_Append(topo_order, node.key)             # <<<<<<<<<<<<<<
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 */
      __pyx_t_1 = __pyx_v_node->key;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_7 = PyList_Append(__pyx_v_topo_order, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":542
 *             node = _get_list_node(pending, last_item)
 *             last_item = last_item - 1
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 *                 # We don't include ghost parents
 *                 PyList_Append(topo_order, node.key)
 */
    }

    /* "breezy/_known_graph_pyx.pyx":545
 *                 # We don't include ghost parents
 *                 PyList_Append(topo_order, node.key)
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):             # <<<<<<<<<<<<<<
 *                 child = _get_list_node(node.children, pos)
 *                 if child.gdfo == -1:
 */
    __pyx_t_1 = __pyx_v_node->children;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_6; __pyx_v_pos++) {

      /* "breezy/_known_graph_pyx.pyx":546
 *                 PyList_Append(topo_order, node.key)
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)             # <<<<<<<<<<<<<<
 *                 if child.gdfo == -1:
 *                     # We know we have a graph cycle because a node has a parent
 */
      __pyx_t_1 = __pyx_v_node->children;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_child, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":547
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 *                 if child.gdfo == -1:             # <<<<<<<<<<<<<<
 *                     # We know we have a graph cycle because a node has a parent
 *                     # which we couldn't find
 */
      __pyx_t_5 = ((__pyx_v_child->gdfo == -1L) != 0);
      if (unlikely(__pyx_t_5)) {

        /* "breezy/_known_graph_pyx.pyx":550
 *                     # We know we have a graph cycle because a node has a parent
 *                     # which we couldn't find
 *                     raise errors.GraphCycleError(self._nodes)             # <<<<<<<<<<<<<<
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 550, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_GraphCycleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 550, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_self->_nodes) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->_nodes);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(0, 550, __pyx_L1_error)

        /* "breezy/_known_graph_pyx.pyx":547
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 *                 child = _get_list_node(node.children, pos)
 *                 if child.gdfo == -1:             # <<<<<<<<<<<<<<
 *                     # We know we have a graph cycle because a node has a parent
 *                     # which we couldn't find
 */
      }

      /* "breezy/_known_graph_pyx.pyx":551
 *                     # which we couldn't find
 *                     raise errors.GraphCycleError(self._nodes)
 *                 child.seen = child.seen + 1             # <<<<<<<<<<<<<<
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 *                     # All parents of this child have been yielded, queue this
 */
      __pyx_v_child->seen = (__pyx_v_child->seen + 1);

      /* "breezy/_known_graph_pyx.pyx":552
 *                     raise errors.GraphCycleError(self._nodes)
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 *                     # All parents of this child have been yielded, queue this
 *                     # one to be yielded as well
 */
      __pyx_t_3 = __pyx_v_child->parents;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_5 = ((__pyx_v_child->seen == PyTuple_GET_SIZE(__pyx_t_3)) != 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_5) {

        /* "breezy/_known_graph_pyx.pyx":555
 *                     # All parents of this child have been yielded, queue this
 *                     # one to be yielded as well
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref
 */
        __pyx_v_last_item = (__pyx_v_last_item + 1);

        /* "breezy/_known_graph_pyx.pyx":556
 *                     # one to be yielded as well
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)
 */
        __pyx_t_5 = ((__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending)) != 0);
        if (__pyx_t_5) {

          /* "breezy/_known_graph_pyx.pyx":557
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref             # <<<<<<<<<<<<<<
 *                         PyList_SetItem(pending, last_item, child)
 *                     else:
 */
          Py_INCREF(((PyObject *)__pyx_v_child));

          /* "breezy/_known_graph_pyx.pyx":558
 *                     if last_item < PyList_GET_SIZE(pending):
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)             # <<<<<<<<<<<<<<
 *                     else:
 *                         PyList_Append(pending, child)
 */
          __pyx_t_7 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 558, __pyx_L1_error)

          /* "breezy/_known_graph_pyx.pyx":556
 *                     # one to be yielded as well
 *                     last_item = last_item + 1
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                         Py_INCREF(child) # SetItem steals a ref
 *                         PyList_SetItem(pending, last_item, child)
 */
          goto __pyx_L13;
        }

        /* "breezy/_known_graph_pyx.pyx":560
 *                         PyList_SetItem(pending, last_item, child)
 *                     else:
 *                         PyList_Append(pending, child)             # <<<<<<<<<<<<<<
 *                     # We have queued this node, we don't need to track it
 *                     # anymore
 */
        /*else*/ {
          __pyx_t_7 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 560, __pyx_L1_error)
        }
        __pyx_L13:;

        /* "breezy/_known_graph_pyx.pyx":563
 *                     # We have queued this node, we don't need to track it
 *                     # anymore
 *                     child.seen = 0             # <<<<<<<<<<<<<<
 *         # We started from the parents, so we don't need to do anymore work
 *         return topo_order
 */
        __pyx_v_child->seen = 0;

        /* "breezy/_known_graph_pyx.pyx":552
 *                     raise errors.GraphCycleError(self._nodes)
 *                 child.seen = child.seen + 1
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 *                     # All parents of this child have been yielded, queue this
 *                     # one to be yielded as well
 */
      }
    }
  }

  /* "breezy/_known_graph_pyx.pyx":565
 *                     child.seen = 0
 *         # We started from the parents, so we don't need to do anymore work
 *         return topo_order             # <<<<<<<<<<<<<<
 * 
 *     def gc_sort(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_topo_order);
  __pyx_r = __pyx_v_topo_order;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":513
 *         return heads
 * 
 *     def topo_sort(self):             # <<<<<<<<<<<<<<
 *         """Return the nodes in topological order.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.topo_sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_pending);
  __Pyx_XDECREF(__pyx_v_topo_order);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":567
 *         return topo_order
 * 
 *     def gc_sort(self):             # <<<<<<<<<<<<<<
 *         """Return a reverse topological ordering which is 'stable'.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_19gc_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_18gc_sort[] = "Return a reverse topological ordering which is 'stable'.\n\n        There are a few constraints:\n          1) Reverse topological (all children before all parents)\n          2) Grouped by prefix\n          3) 'stable' sorting, so that we get the same result, independent of\n             machine, or extra data.\n        To do this, we use the same basic algorithm as topo_sort, but when we\n        aren't sure what node to access next, we sort them lexicographically.\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_19gc_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("gc_sort (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_18gc_sort(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_18gc_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_v_temp;
  Py_ssize_t __pyx_v_pos;
  Py_ssize_t __pyx_v_last_item;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node = 0;
  PyObject *__pyx_v_tips = NULL;
  PyObject *__pyx_v_prefix_tips = NULL;
  PyObject *__pyx_v_prefix = NULL;
  PyObject *__pyx_v_tip_nodes = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_pending = NULL;
  PyObject *__pyx_v_parents = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("gc_sort", 0);

  /* "breezy/_known_graph_pyx.pyx":582
 *         cdef _KnownGraphNode node, node2, parent_node
 * 
 *         tips = self._find_tips()             # <<<<<<<<<<<<<<
 *         # Split the tips based on prefix
 *         prefix_tips = {}
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_tips); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_tips = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":584
 *         tips = self._find_tips()
 *         # Split the tips based on prefix
 *         prefix_tips = {}             # <<<<<<<<<<<<<<
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 *             node = _get_list_node(tips, pos)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_prefix_tips = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":585
 *         # Split the tips based on prefix
 *         prefix_tips = {}
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):             # <<<<<<<<<<<<<<
 *             node = _get_list_node(tips, pos)
 *             if PyBytes_CheckExact(node.key) or len(node.key) == 1:
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_tips);
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {

    /* "breezy/_known_graph_pyx.pyx":586
 *         prefix_tips = {}
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 *             node = _get_list_node(tips, pos)             # <<<<<<<<<<<<<<
 *             if PyBytes_CheckExact(node.key) or len(node.key) == 1:
 *                 prefix = ''
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_tips, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":587
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 *             node = _get_list_node(tips, pos)
 *             if PyBytes_CheckExact(node.key) or len(node.key) == 1:             # <<<<<<<<<<<<<<
 *                 prefix = ''
 *             else:
 */
    __pyx_t_1 = __pyx_v_node->key;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = (PyBytes_CheckExact(__pyx_t_1) != 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = __pyx_v_node->key;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 587, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = ((__pyx_t_7 == 1) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "breezy/_known_graph_pyx.pyx":588
 *             node = _get_list_node(tips, pos)
 *             if PyBytes_CheckExact(node.key) or len(node.key) == 1:
 *                 prefix = ''             # <<<<<<<<<<<<<<
 *             else:
 *                 prefix = node.key[0]
 */
      __Pyx_INCREF(__pyx_kp_s__3);
      __Pyx_XDECREF_SET(__pyx_v_prefix, __pyx_kp_s__3);

      /* "breezy/_known_graph_pyx.pyx":587
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 *             node = _get_list_node(tips, pos)
 *             if PyBytes_CheckExact(node.key) or len(node.key) == 1:             # <<<<<<<<<<<<<<
 *                 prefix = ''
 *             else:
 */
      goto __pyx_L5;
    }

    /* "breezy/_known_graph_pyx.pyx":590
 *                 prefix = ''
 *             else:
 *                 prefix = node.key[0]             # <<<<<<<<<<<<<<
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             if temp == NULL:
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_node->key, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_prefix, __pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L5:;

    /* "breezy/_known_graph_pyx.pyx":591
 *             else:
 *                 prefix = node.key[0]
 *             temp = PyDict_GetItem(prefix_tips, prefix)             # <<<<<<<<<<<<<<
 *             if temp == NULL:
 *                 prefix_tips[prefix] = [node]
 */
    __pyx_v_temp = PyDict_GetItem(__pyx_v_prefix_tips, __pyx_v_prefix);

    /* "breezy/_known_graph_pyx.pyx":592
 *                 prefix = node.key[0]
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 *                 prefix_tips[prefix] = [node]
 *             else:
 */
    __pyx_t_5 = ((__pyx_v_temp == NULL) != 0);
    if (__pyx_t_5) {

      /* "breezy/_known_graph_pyx.pyx":593
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             if temp == NULL:
 *                 prefix_tips[prefix] = [node]             # <<<<<<<<<<<<<<
 *             else:
 *                 tip_nodes = <object>temp
 */
      __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_node));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
      PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_node));
      if (unlikely(PyDict_SetItem(__pyx_v_prefix_tips, __pyx_v_prefix, __pyx_t_1) < 0)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":592
 *                 prefix = node.key[0]
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 *                 prefix_tips[prefix] = [node]
 *             else:
 */
      goto __pyx_L8;
    }

    /* "breezy/_known_graph_pyx.pyx":595
 *                 prefix_tips[prefix] = [node]
 *             else:
 *                 tip_nodes = <object>temp             # <<<<<<<<<<<<<<
 *                 PyList_Append(tip_nodes, node)
 * 
 */
    /*else*/ {
      __pyx_t_1 = ((PyObject *)__pyx_v_temp);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_tip_nodes, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":596
 *             else:
 *                 tip_nodes = <object>temp
 *                 PyList_Append(tip_nodes, node)             # <<<<<<<<<<<<<<
 * 
 *         result = []
 */
      __pyx_t_8 = PyList_Append(__pyx_v_tip_nodes, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 596, __pyx_L1_error)
    }
    __pyx_L8:;
  }

  /* "breezy/_known_graph_pyx.pyx":598
 *                 PyList_Append(tip_nodes, node)
 * 
 *         result = []             # <<<<<<<<<<<<<<
 *         for prefix in sorted(prefix_tips):
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":599
 * 
 *         result = []
 *         for prefix in sorted(prefix_tips):             # <<<<<<<<<<<<<<
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             assert temp != NULL
 */
  __pyx_t_2 = PySequence_List(__pyx_v_prefix_tips); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_9 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 599, __pyx_L1_error)
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 599, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 599, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_prefix, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":600
 *         result = []
 *         for prefix in sorted(prefix_tips):
 *             temp = PyDict_GetItem(prefix_tips, prefix)             # <<<<<<<<<<<<<<
 *             assert temp != NULL
 *             tip_nodes = <object>temp
 */
    __pyx_v_temp = PyDict_GetItem(__pyx_v_prefix_tips, __pyx_v_prefix);

    /* "breezy/_known_graph_pyx.pyx":601
 *         for prefix in sorted(prefix_tips):
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             assert temp != NULL             # <<<<<<<<<<<<<<
 *             tip_nodes = <object>temp
 *             pending = _sort_list_nodes(tip_nodes, 1)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!((__pyx_v_temp != NULL) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 601, __pyx_L1_error)
      }
    }
    #endif

    /* "breezy/_known_graph_pyx.pyx":602
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             assert temp != NULL
 *             tip_nodes = <object>temp             # <<<<<<<<<<<<<<
 *             pending = _sort_list_nodes(tip_nodes, 1)
 *             last_item = PyList_GET_SIZE(pending) - 1
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_temp);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_tip_nodes, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":603
 *             assert temp != NULL
 *             tip_nodes = <object>temp
 *             pending = _sort_list_nodes(tip_nodes, 1)             # <<<<<<<<<<<<<<
 *             last_item = PyList_GET_SIZE(pending) - 1
 *             while last_item >= 0:
 */
    __pyx_t_1 = __pyx_f_6breezy_16_known_graph_pyx__sort_list_nodes(__pyx_v_tip_nodes, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_pending, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":604
 *             tip_nodes = <object>temp
 *             pending = _sort_list_nodes(tip_nodes, 1)
 *             last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 *             while last_item >= 0:
 *                 node = _get_list_node(pending, last_item)
 */
    __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);

    /* "breezy/_known_graph_pyx.pyx":605
 *             pending = _sort_list_nodes(tip_nodes, 1)
 *             last_item = PyList_GET_SIZE(pending) - 1
 *             while last_item >= 0:             # <<<<<<<<<<<<<<
 *                 node = _get_list_node(pending, last_item)
 *                 last_item = last_item - 1
 */
    while (1) {
      __pyx_t_5 = ((__pyx_v_last_item >= 0) != 0);
      if (!__pyx_t_5) break;

      /* "breezy/_known_graph_pyx.pyx":606
 *             last_item = PyList_GET_SIZE(pending) - 1
 *             while last_item >= 0:
 *                 node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 *                 last_item = last_item - 1
 *                 if node.parents is None:
 */
      __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 606, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":607
 *             while last_item >= 0:
 *                 node = _get_list_node(pending, last_item)
 *                 last_item = last_item - 1             # <<<<<<<<<<<<<<
 *                 if node.parents is None:
 *                     # Ghost
 */
      __pyx_v_last_item = (__pyx_v_last_item - 1);

      /* "breezy/_known_graph_pyx.pyx":608
 *                 node = _get_list_node(pending, last_item)
 *                 last_item = last_item - 1
 *                 if node.parents is None:             # <<<<<<<<<<<<<<
 *                     # Ghost
 *                     continue
 */
      __pyx_t_5 = (__pyx_v_node->parents == Py_None);
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (__pyx_t_6) {

        /* "breezy/_known_graph_pyx.pyx":610
 *                 if node.parents is None:
 *                     # Ghost
 *                     continue             # <<<<<<<<<<<<<<
 *                 PyList_Append(result, node.key)
 *                 # Sorting the parent keys isn't strictly necessary for stable
 */
        goto __pyx_L11_continue;

        /* "breezy/_known_graph_pyx.pyx":608
 *                 node = _get_list_node(pending, last_item)
 *                 last_item = last_item - 1
 *                 if node.parents is None:             # <<<<<<<<<<<<<<
 *                     # Ghost
 *                     continue
 */
      }

      /* "breezy/_known_graph_pyx.pyx":611
 *                     # Ghost
 *                     continue
 *                 PyList_Append(result, node.key)             # <<<<<<<<<<<<<<
 *                 # Sorting the parent keys isn't strictly necessary for stable
 *                 # sorting of a given graph. But it does help minimize the
 */
      __pyx_t_1 = __pyx_v_node->key;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_8 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":618
 *                 #   4.73ms  no sort
 *                 #   7.73ms  RichCompareBool sort
 *                 parents = _sort_list_nodes(node.parents, 1)             # <<<<<<<<<<<<<<
 *                 for pos from 0 <= pos < len(parents):
 *                     if PyTuple_CheckExact(parents):
 */
      __pyx_t_1 = __pyx_v_node->parents;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_f_6breezy_16_known_graph_pyx__sort_list_nodes(__pyx_t_1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_parents, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":619
 *                 #   7.73ms  RichCompareBool sort
 *                 parents = _sort_list_nodes(node.parents, 1)
 *                 for pos from 0 <= pos < len(parents):             # <<<<<<<<<<<<<<
 *                     if PyTuple_CheckExact(parents):
 *                         parent_node = _get_tuple_node(parents, pos)
 */
      __pyx_t_7 = PyObject_Length(__pyx_v_parents); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 619, __pyx_L1_error)
      for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_7; __pyx_v_pos++) {

        /* "breezy/_known_graph_pyx.pyx":620
 *                 parents = _sort_list_nodes(node.parents, 1)
 *                 for pos from 0 <= pos < len(parents):
 *                     if PyTuple_CheckExact(parents):             # <<<<<<<<<<<<<<
 *                         parent_node = _get_tuple_node(parents, pos)
 *                     else:
 */
        __pyx_t_6 = (PyTuple_CheckExact(__pyx_v_parents) != 0);
        if (__pyx_t_6) {

          /* "breezy/_known_graph_pyx.pyx":621
 *                 for pos from 0 <= pos < len(parents):
 *                     if PyTuple_CheckExact(parents):
 *                         parent_node = _get_tuple_node(parents, pos)             # <<<<<<<<<<<<<<
 *                     else:
 *                         parent_node = _get_list_node(parents, pos)
 */
          __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_v_parents, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
          __pyx_t_3 = 0;

          /* "breezy/_known_graph_pyx.pyx":620
 *                 parents = _sort_list_nodes(node.parents, 1)
 *                 for pos from 0 <= pos < len(parents):
 *                     if PyTuple_CheckExact(parents):             # <<<<<<<<<<<<<<
 *                         parent_node = _get_tuple_node(parents, pos)
 *                     else:
 */
          goto __pyx_L16;
        }

        /* "breezy/_known_graph_pyx.pyx":623
 *                         parent_node = _get_tuple_node(parents, pos)
 *                     else:
 *                         parent_node = _get_list_node(parents, pos)             # <<<<<<<<<<<<<<
 *                     # TODO: GraphCycle detection
 *                     parent_node.seen = parent_node.seen + 1
 */
        /*else*/ {
          __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_v_parents, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
          __pyx_t_3 = 0;
        }
        __pyx_L16:;

        /* "breezy/_known_graph_pyx.pyx":625
 *                         parent_node = _get_list_node(parents, pos)
 *                     # TODO: GraphCycle detection
 *                     parent_node.seen = parent_node.seen + 1             # <<<<<<<<<<<<<<
 *                     if (parent_node.seen
 *                         == PyList_GET_SIZE(parent_node.children)):
 */
        __pyx_v_parent_node->seen = (__pyx_v_parent_node->seen + 1);

        /* "breezy/_known_graph_pyx.pyx":627
 *                     parent_node.seen = parent_node.seen + 1
 *                     if (parent_node.seen
 *                         == PyList_GET_SIZE(parent_node.children)):             # <<<<<<<<<<<<<<
 *                         # All children have been processed, queue up this
 *                         # parent
 */
        __pyx_t_3 = __pyx_v_parent_node->children;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = ((__pyx_v_parent_node->seen == PyList_GET_SIZE(__pyx_t_3)) != 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "breezy/_known_graph_pyx.pyx":626
 *                     # TODO: GraphCycle detection
 *                     parent_node.seen = parent_node.seen + 1
 *                     if (parent_node.seen             # <<<<<<<<<<<<<<
 *                         == PyList_GET_SIZE(parent_node.children)):
 *                         # All children have been processed, queue up this
 */
        if (__pyx_t_6) {

          /* "breezy/_known_graph_pyx.pyx":630
 *                         # All children have been processed, queue up this
 *                         # parent
 *                         last_item = last_item + 1             # <<<<<<<<<<<<<<
 *                         if last_item < PyList_GET_SIZE(pending):
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 */
          __pyx_v_last_item = (__pyx_v_last_item + 1);

          /* "breezy/_known_graph_pyx.pyx":631
 *                         # parent
 *                         last_item = last_item + 1
 *                         if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 *                             PyList_SetItem(pending, last_item, parent_node)
 */
          __pyx_t_6 = ((__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending)) != 0);
          if (__pyx_t_6) {

            /* "breezy/_known_graph_pyx.pyx":632
 *                         last_item = last_item + 1
 *                         if last_item < PyList_GET_SIZE(pending):
 *                             Py_INCREF(parent_node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 *                             PyList_SetItem(pending, last_item, parent_node)
 *                         else:
 */
            Py_INCREF(((PyObject *)__pyx_v_parent_node));

            /* "breezy/_known_graph_pyx.pyx":633
 *                         if last_item < PyList_GET_SIZE(pending):
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 *                             PyList_SetItem(pending, last_item, parent_node)             # <<<<<<<<<<<<<<
 *                         else:
 *                             PyList_Append(pending, parent_node)
 */
            __pyx_t_8 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 633, __pyx_L1_error)

            /* "breezy/_known_graph_pyx.pyx":631
 *                         # parent
 *                         last_item = last_item + 1
 *                         if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 *                             PyList_SetItem(pending, last_item, parent_node)
 */
            goto __pyx_L18;
          }

          /* "breezy/_known_graph_pyx.pyx":635
 *                             PyList_SetItem(pending, last_item, parent_node)
 *                         else:
 *                             PyList_Append(pending, parent_node)             # <<<<<<<<<<<<<<
 *                         parent_node.seen = 0
 *         return result
 */
          /*else*/ {
            __pyx_t_8 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 635, __pyx_L1_error)
          }
          __pyx_L18:;

          /* "breezy/_known_graph_pyx.pyx":636
 *                         else:
 *                             PyList_Append(pending, parent_node)
 *                         parent_node.seen = 0             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
          __pyx_v_parent_node->seen = 0;

          /* "breezy/_known_graph_pyx.pyx":626
 *                     # TODO: GraphCycle detection
 *                     parent_node.seen = parent_node.seen + 1
 *                     if (parent_node.seen             # <<<<<<<<<<<<<<
 *                         == PyList_GET_SIZE(parent_node.children)):
 *                         # All children have been processed, queue up this
 */
        }
      }
      __pyx_L11_continue:;
    }

    /* "breezy/_known_graph_pyx.pyx":599
 * 
 *         result = []
 *         for prefix in sorted(prefix_tips):             # <<<<<<<<<<<<<<
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 *             assert temp != NULL
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":637
 *                             PyList_Append(pending, parent_node)
 *                         parent_node.seen = 0
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def merge_sort(self, tip_key):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":567
 *         return topo_order
 * 
 *     def gc_sort(self):             # <<<<<<<<<<<<<<
 *         """Return a reverse topological ordering which is 'stable'.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.gc_sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_node);
  __Pyx_XDECREF(__pyx_v_tips);
  __Pyx_XDECREF(__pyx_v_prefix_tips);
  __Pyx_XDECREF(__pyx_v_prefix);
  __Pyx_XDECREF(__pyx_v_tip_nodes);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_pending);
  __Pyx_XDECREF(__pyx_v_parents);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":639
 *         return result
 * 
 *     def merge_sort(self, tip_key):             # <<<<<<<<<<<<<<
 *         """Compute the merge sorted graph output."""
 *         cdef _MergeSorter sorter
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_21merge_sort(PyObject *__pyx_v_self, PyObject *__pyx_v_tip_key); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_20merge_sort[] = "Compute the merge sorted graph output.";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_21merge_sort(PyObject *__pyx_v_self, PyObject *__pyx_v_tip_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge_sort (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_20merge_sort(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_tip_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_20merge_sort(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_tip_key) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_sorter = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("merge_sort", 0);

  /* "breezy/_known_graph_pyx.pyx":646
 *         #       that won't be collectable anyway. real world testing has not
 *         #       shown a specific impact, yet.
 *         sorter = _MergeSorter(self, tip_key)             # <<<<<<<<<<<<<<
 *         return sorter.topo_order()
 * 
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_tip_key);
  __Pyx_GIVEREF(__pyx_v_tip_key);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tip_key);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__MergeSorter), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_sorter = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":647
 *         #       shown a specific impact, yet.
 *         sorter = _MergeSorter(self, tip_key)
 *         return sorter.topo_order()             # <<<<<<<<<<<<<<
 * 
 *     def get_parent_keys(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_sorter->__pyx_vtab)->topo_order(__pyx_v_sorter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":639
 *         return result
 * 
 *     def merge_sort(self, tip_key):             # <<<<<<<<<<<<<<
 *         """Compute the merge sorted graph output."""
 *         cdef _MergeSorter sorter
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.merge_sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sorter);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":649
 *         return sorter.topo_order()
 * 
 *     def get_parent_keys(self, key):             # <<<<<<<<<<<<<<
 *         """Get the parents for a key
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_23get_parent_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_22get_parent_keys[] = "Get the parents for a key\n\n        Returns a list containing the parents keys. If the key is a ghost,\n        None is returned. A KeyError will be raised if the key is not in\n        the graph.\n\n        :param keys: Key to check (eg revision_id)\n        :return: A list of parents\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_23get_parent_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_parent_keys (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_22get_parent_keys(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_22get_parent_keys(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_parent_keys", 0);

  /* "breezy/_known_graph_pyx.pyx":659
 *         :return: A list of parents
 *         """
 *         return self._nodes[key].parent_keys             # <<<<<<<<<<<<<<
 * 
 *     def get_child_keys(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->_nodes, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_parent_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":649
 *         return sorter.topo_order()
 * 
 *     def get_parent_keys(self, key):             # <<<<<<<<<<<<<<
 *         """Get the parents for a key
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.get_parent_keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":661
 *         return self._nodes[key].parent_keys
 * 
 *     def get_child_keys(self, key):             # <<<<<<<<<<<<<<
 *         """Get the children for a key
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_25get_child_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_24get_child_keys[] = "Get the children for a key\n\n        Returns a list containing the children keys. A KeyError will be raised\n        if the key is not in the graph.\n\n        :param keys: Key to check (eg revision_id)\n        :return: A list of children\n        ";
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_25get_child_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_child_keys (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_24get_child_keys(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_24get_child_keys(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_child_keys", 0);

  /* "breezy/_known_graph_pyx.pyx":670
 *         :return: A list of children
 *         """
 *         return self._nodes[key].child_keys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->_nodes, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_child_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":661
 *         return self._nodes[key].parent_keys
 * 
 *     def get_child_keys(self, key):             # <<<<<<<<<<<<<<
 *         """Get the children for a key
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.get_child_keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":200
 *     """This is a class which assumes we already know the full graph."""
 * 
 *     cdef public object _nodes             # <<<<<<<<<<<<<<
 *     cdef public object _known_heads
 *     cdef public int do_cache
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_nodes);
  __pyx_r = __pyx_v_self->_nodes;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_nodes);
  __Pyx_DECREF(__pyx_v_self->_nodes);
  __pyx_v_self->_nodes = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_4__del__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_nodes);
  __Pyx_DECREF(__pyx_v_self->_nodes);
  __pyx_v_self->_nodes = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":201
 * 
 *     cdef public object _nodes
 *     cdef public object _known_heads             # <<<<<<<<<<<<<<
 *     cdef public int do_cache
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_known_heads);
  __pyx_r = __pyx_v_self->_known_heads;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_known_heads);
  __Pyx_DECREF(__pyx_v_self->_known_heads);
  __pyx_v_self->_known_heads = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_4__del__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_known_heads);
  __Pyx_DECREF(__pyx_v_self->_known_heads);
  __pyx_v_self->_known_heads = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":202
 *     cdef public object _nodes
 *     cdef public object _known_heads
 *     cdef public int do_cache             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, parent_map, do_cache=True):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache___get__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->do_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.do_cache.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error)
  __pyx_v_self->do_cache = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.do_cache.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_27__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_27__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_26__reduce_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_26__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._known_heads, self._nodes, self.do_cache)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->do_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_known_heads);
  __Pyx_GIVEREF(__pyx_v_self->_known_heads);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_known_heads);
  __Pyx_INCREF(__pyx_v_self->_nodes);
  __Pyx_GIVEREF(__pyx_v_self->_nodes);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->_nodes);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._known_heads, self._nodes, self.do_cache)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self._known_heads, self._nodes, self.do_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._known_heads is not None or self._nodes is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._known_heads, self._nodes, self.do_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._known_heads is not None or self._nodes is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_known_heads != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_nodes != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._known_heads is not None or self._nodes is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self._known_heads is not None or self._nodes is not None
 *     if use_setstate:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_KnownGraph); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_117422769);
    __Pyx_GIVEREF(__pyx_int_117422769);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_117422769);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._known_heads is not None or self._nodes is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, None), state
 *     else:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_KnownGraph__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_KnownGraph); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_117422769);
    __Pyx_GIVEREF(__pyx_int_117422769);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_117422769);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_KnownGraph__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_29__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_29__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_28__setstate_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_10KnownGraph_28__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_KnownGraph__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle_KnownGraph__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_KnownGraph, (type(self), 0x6ffbab1, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_KnownGraph__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx.KnownGraph.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":693
 *     cdef int completed # Fully Processed
 * 
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 *         self.key = key
 *         self.merge_depth = -1
 */

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 693, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 693, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode___init__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self), __pyx_v_key);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "breezy/_known_graph_pyx.pyx":694
 * 
 *     def __init__(self, key):
 *         self.key = key             # <<<<<<<<<<<<<<
 *         self.merge_depth = -1
 *         self.left_parent = None
 */
  __Pyx_INCREF(__pyx_v_key);
  __Pyx_GIVEREF(__pyx_v_key);
  __Pyx_GOTREF(__pyx_v_self->key);
  __Pyx_DECREF(__pyx_v_self->key);
  __pyx_v_self->key = __pyx_v_key;

  /* "breezy/_known_graph_pyx.pyx":695
 *     def __init__(self, key):
 *         self.key = key
 *         self.merge_depth = -1             # <<<<<<<<<<<<<<
 *         self.left_parent = None
 *         self.left_pending_parent = None
 */
  __pyx_v_self->merge_depth = -1L;

  /* "breezy/_known_graph_pyx.pyx":696
 *         self.key = key
 *         self.merge_depth = -1
 *         self.left_parent = None             # <<<<<<<<<<<<<<
 *         self.left_pending_parent = None
 *         self.pending_parents = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->left_parent);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->left_parent));
  __pyx_v_self->left_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None);

  /* "breezy/_known_graph_pyx.pyx":697
 *         self.merge_depth = -1
 *         self.left_parent = None
 *         self.left_pending_parent = None             # <<<<<<<<<<<<<<
 *         self.pending_parents = None
 *         self._revno_first = -1
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->left_pending_parent);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->left_pending_parent));
  __pyx_v_self->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None);

  /* "breezy/_known_graph_pyx.pyx":698
 *         self.left_parent = None
 *         self.left_pending_parent = None
 *         self.pending_parents = None             # <<<<<<<<<<<<<<
 *         self._revno_first = -1
 *         self._revno_second = -1
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pending_parents);
  __Pyx_DECREF(__pyx_v_self->pending_parents);
  __pyx_v_self->pending_parents = Py_None;

  /* "breezy/_known_graph_pyx.pyx":699
 *         self.left_pending_parent = None
 *         self.pending_parents = None
 *         self._revno_first = -1             # <<<<<<<<<<<<<<
 *         self._revno_second = -1
 *         self._revno_last = -1
 */
  __pyx_v_self->_revno_first = -1L;

  /* "breezy/_known_graph_pyx.pyx":700
 *         self.pending_parents = None
 *         self._revno_first = -1
 *         self._revno_second = -1             # <<<<<<<<<<<<<<
 *         self._revno_last = -1
 *         self.is_first_child = 0
 */
  __pyx_v_self->_revno_second = -1L;

  /* "breezy/_known_graph_pyx.pyx":701
 *         self._revno_first = -1
 *         self._revno_second = -1
 *         self._revno_last = -1             # <<<<<<<<<<<<<<
 *         self.is_first_child = 0
 *         self.seen_by_child = 0
 */
  __pyx_v_self->_revno_last = -1L;

  /* "breezy/_known_graph_pyx.pyx":702
 *         self._revno_second = -1
 *         self._revno_last = -1
 *         self.is_first_child = 0             # <<<<<<<<<<<<<<
 *         self.seen_by_child = 0
 *         self.completed = 0
 */
  __pyx_v_self->is_first_child = 0;

  /* "breezy/_known_graph_pyx.pyx":703
 *         self._revno_last = -1
 *         self.is_first_child = 0
 *         self.seen_by_child = 0             # <<<<<<<<<<<<<<
 *         self.completed = 0
 * 
 */
  __pyx_v_self->seen_by_child = 0;

  /* "breezy/_known_graph_pyx.pyx":704
 *         self.is_first_child = 0
 *         self.seen_by_child = 0
 *         self.completed = 0             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_v_self->completed = 0;

  /* "breezy/_known_graph_pyx.pyx":693
 *     cdef int completed # Fully Processed
 * 
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 *         self.key = key
 *         self.merge_depth = -1
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":706
 *         self.completed = 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 *             self.__class__.__name__, self.key,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_2__repr__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_2__repr__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "breezy/_known_graph_pyx.pyx":707
 * 
 *     def __repr__(self):
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (             # <<<<<<<<<<<<<<
 *             self.__class__.__name__, self.key,
 *             self.merge_depth,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "breezy/_known_graph_pyx.pyx":708
 *     def __repr__(self):
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 *             self.__class__.__name__, self.key,             # <<<<<<<<<<<<<<
 *             self.merge_depth,
 *             self._revno_first, self._revno_second, self._revno_last,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":709
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 *             self.__class__.__name__, self.key,
 *             self.merge_depth,             # <<<<<<<<<<<<<<
 *             self._revno_first, self._revno_second, self._revno_last,
 *             self.is_first_child, self.seen_by_child)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->merge_depth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "breezy/_known_graph_pyx.pyx":710
 *             self.__class__.__name__, self.key,
 *             self.merge_depth,
 *             self._revno_first, self._revno_second, self._revno_last,             # <<<<<<<<<<<<<<
 *             self.is_first_child, self.seen_by_child)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_first); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_second); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "breezy/_known_graph_pyx.pyx":711
 *             self.merge_depth,
 *             self._revno_first, self._revno_second, self._revno_last,
 *             self.is_first_child, self.seen_by_child)             # <<<<<<<<<<<<<<
 * 
 *     cdef int has_pending_parents(self): # cannot_raise
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->is_first_child); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->seen_by_child); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "breezy/_known_graph_pyx.pyx":708
 *     def __repr__(self):
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 *             self.__class__.__name__, self.key,             # <<<<<<<<<<<<<<
 *             self.merge_depth,
 *             self._revno_first, self._revno_second, self._revno_last,
 */
  __pyx_t_8 = PyTuple_New(8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_v_self->key);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;

  /* "breezy/_known_graph_pyx.pyx":707
 * 
 *     def __repr__(self):
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (             # <<<<<<<<<<<<<<
 *             self.__class__.__name__, self.key,
 *             self.merge_depth,
 */
  __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s_depth_s_rev_s_s_s_first_s_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 707, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":706
 *         self.completed = 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 *             self.__class__.__name__, self.key,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":713
 *             self.is_first_child, self.seen_by_child)
 * 
 *     cdef int has_pending_parents(self): # cannot_raise             # <<<<<<<<<<<<<<
 *         if self.left_pending_parent is not None or self.pending_parents:
 *             return 1
 */

static int __pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode_has_pending_parents(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("has_pending_parents", 0);

  /* "breezy/_known_graph_pyx.pyx":714
 * 
 *     cdef int has_pending_parents(self): # cannot_raise
 *         if self.left_pending_parent is not None or self.pending_parents:             # <<<<<<<<<<<<<<
 *             return 1
 *         return 0
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->left_pending_parent) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->pending_parents); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 714, __pyx_L1_error)
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "breezy/_known_graph_pyx.pyx":715
 *     cdef int has_pending_parents(self): # cannot_raise
 *         if self.left_pending_parent is not None or self.pending_parents:
 *             return 1             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":714
 * 
 *     cdef int has_pending_parents(self): # cannot_raise
 *         if self.left_pending_parent is not None or self.pending_parents:             # <<<<<<<<<<<<<<
 *             return 1
 *         return 0
 */
  }

  /* "breezy/_known_graph_pyx.pyx":716
 *         if self.left_pending_parent is not None or self.pending_parents:
 *             return 1
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef object _revno(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":713
 *             self.is_first_child, self.seen_by_child)
 * 
 *     cdef int has_pending_parents(self): # cannot_raise             # <<<<<<<<<<<<<<
 *         if self.left_pending_parent is not None or self.pending_parents:
 *             return 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("breezy._known_graph_pyx._MergeSortNode.has_pending_parents", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":718
 *         return 0
 * 
 *     cdef object _revno(self):             # <<<<<<<<<<<<<<
 *         if self._revno_first == -1:
 *             if self._revno_second != -1:
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode__revno(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_revno", 0);

  /* "breezy/_known_graph_pyx.pyx":719
 * 
 *     cdef object _revno(self):
 *         if self._revno_first == -1:             # <<<<<<<<<<<<<<
 *             if self._revno_second != -1:
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 */
  __pyx_t_1 = ((__pyx_v_self->_revno_first == -1L) != 0);
  if (__pyx_t_1) {

    /* "breezy/_known_graph_pyx.pyx":720
 *     cdef object _revno(self):
 *         if self._revno_first == -1:
 *             if self._revno_second != -1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 *             return (self._revno_last,)
 */
    __pyx_t_1 = ((__pyx_v_self->_revno_second != -1L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "breezy/_known_graph_pyx.pyx":721
 *         if self._revno_first == -1:
 *             if self._revno_second != -1:
 *                 raise RuntimeError('Something wrong with: %s' % (self,))             # <<<<<<<<<<<<<<
 *             return (self._revno_last,)
 *         else:
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Something_wrong_with_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 721, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 721, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":720
 *     cdef object _revno(self):
 *         if self._revno_first == -1:
 *             if self._revno_second != -1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 *             return (self._revno_last,)
 */
    }

    /* "breezy/_known_graph_pyx.pyx":722
 *             if self._revno_second != -1:
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 *             return (self._revno_last,)             # <<<<<<<<<<<<<<
 *         else:
 *             return (self._revno_first, self._revno_second, self._revno_last)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "breezy/_known_graph_pyx.pyx":719
 * 
 *     cdef object _revno(self):
 *         if self._revno_first == -1:             # <<<<<<<<<<<<<<
 *             if self._revno_second != -1:
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 */
  }

  /* "breezy/_known_graph_pyx.pyx":724
 *             return (self._revno_last,)
 *         else:
 *             return (self._revno_first, self._revno_second, self._revno_last)             # <<<<<<<<<<<<<<
 * 
 *     property revno:
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_first); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_second); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
  }

  /* "breezy/_known_graph_pyx.pyx":718
 *         return 0
 * 
 *     cdef object _revno(self):             # <<<<<<<<<<<<<<
 *         if self._revno_first == -1:
 *             if self._revno_second != -1:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode._revno", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":727
 * 
 *     property revno:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._revno()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "breezy/_known_graph_pyx.pyx":728
 *     property revno:
 *         def __get__(self):
 *             return self._revno()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self->__pyx_vtab)->_revno(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":727
 * 
 *     property revno:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._revno()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.revno.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":677
 * 
 *     # Public api
 *     cdef public object key             # <<<<<<<<<<<<<<
 *     cdef public long merge_depth
 *     cdef public object end_of_merge # True/False Is this the end of the current merge
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->key);
  __pyx_r = __pyx_v_self->key;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->key);
  __Pyx_DECREF(__pyx_v_self->key);
  __pyx_v_self->key = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_4__del__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->key);
  __Pyx_DECREF(__pyx_v_self->key);
  __pyx_v_self->key = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":678
 *     # Public api
 *     cdef public object key
 *     cdef public long merge_depth             # <<<<<<<<<<<<<<
 *     cdef public object end_of_merge # True/False Is this the end of the current merge
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->merge_depth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.merge_depth.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_value); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 678, __pyx_L1_error)
  __pyx_v_self->merge_depth = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.merge_depth.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":679
 *     cdef public object key
 *     cdef public long merge_depth
 *     cdef public object end_of_merge # True/False Is this the end of the current merge             # <<<<<<<<<<<<<<
 * 
 *     # Private api, used while computing the information
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->end_of_merge);
  __pyx_r = __pyx_v_self->end_of_merge;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__set__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__set__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->end_of_merge);
  __Pyx_DECREF(__pyx_v_self->end_of_merge);
  __pyx_v_self->end_of_merge = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_4__del__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_4__del__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->end_of_merge);
  __Pyx_DECREF(__pyx_v_self->end_of_merge);
  __pyx_v_self->end_of_merge = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_4__reduce_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_4__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._revno_first, self._revno_last, self._revno_second, self.completed, self.end_of_merge, self.is_first_child, self.key, self.left_parent, self.left_pending_parent, self.merge_depth, self.pending_parents, self.seen_by_child)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_first); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_self->_revno_second); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->completed); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->is_first_child); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_self->merge_depth); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->seen_by_child); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(12); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->end_of_merge);
  __Pyx_GIVEREF(__pyx_v_self->end_of_merge);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_self->end_of_merge);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->key);
  __Pyx_GIVEREF(__pyx_v_self->key);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_v_self->key);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->left_parent));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->left_parent));
  PyTuple_SET_ITEM(__pyx_t_8, 7, ((PyObject *)__pyx_v_self->left_parent));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->left_pending_parent));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->left_pending_parent));
  PyTuple_SET_ITEM(__pyx_t_8, 8, ((PyObject *)__pyx_v_self->left_pending_parent));
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 9, __pyx_t_6);
  __Pyx_INCREF(__pyx_v_self->pending_parents);
  __Pyx_GIVEREF(__pyx_v_self->pending_parents);
  PyTuple_SET_ITEM(__pyx_t_8, 10, __pyx_v_self->pending_parents);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 11, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._revno_first, self._revno_last, self._revno_second, self.completed, self.end_of_merge, self.is_first_child, self.key, self.left_parent, self.left_pending_parent, self.merge_depth, self.pending_parents, self.seen_by_child)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_8 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v__dict = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "(tree fragment)":7
 *     state = (self._revno_first, self._revno_last, self._revno_second, self.completed, self.end_of_merge, self.is_first_child, self.key, self.left_parent, self.left_pending_parent, self.merge_depth, self.pending_parents, self.seen_by_child)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_9 = (__pyx_v__dict != Py_None);
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v__dict);
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.end_of_merge is not None or self.key is not None or self.left_parent is not None or self.left_pending_parent is not None or self.pending_parents is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._revno_first, self._revno_last, self._revno_second, self.completed, self.end_of_merge, self.is_first_child, self.key, self.left_parent, self.left_pending_parent, self.merge_depth, self.pending_parents, self.seen_by_child)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.end_of_merge is not None or self.key is not None or self.left_parent is not None or self.left_pending_parent is not None or self.pending_parents is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, None), state
 */
  /*else*/ {
    __pyx_t_9 = (__pyx_v_self->end_of_merge != Py_None);
    __pyx_t_11 = (__pyx_t_9 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_10 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->key != Py_None);
    __pyx_t_9 = (__pyx_t_11 != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_10 = __pyx_t_9;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_9 = (((PyObject *)__pyx_v_self->left_parent) != Py_None);
    __pyx_t_11 = (__pyx_t_9 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_10 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (((PyObject *)__pyx_v_self->left_pending_parent) != Py_None);
    __pyx_t_9 = (__pyx_t_11 != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_10 = __pyx_t_9;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_9 = (__pyx_v_self->pending_parents != Py_None);
    __pyx_t_11 = (__pyx_t_9 != 0);
    __pyx_t_10 = __pyx_t_11;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_10;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.end_of_merge is not None or self.key is not None or self.left_parent is not None or self.left_pending_parent is not None or self.pending_parents is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, None), state
 *     else:
 */
  __pyx_t_10 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_10) {

    /* "(tree fragment)":13
 *         use_setstate = self.end_of_merge is not None or self.key is not None or self.left_parent is not None or self.left_pending_parent is not None or self.pending_parents is not None
 *     if use_setstate:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pyx_unpickle__MergeSortNode); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_128118063);
    __Pyx_GIVEREF(__pyx_int_128118063);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_128118063);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_8, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.end_of_merge is not None or self.key is not None or self.left_parent is not None or self.left_pending_parent is not None or self.pending_parents is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, None), state
 *     else:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__MergeSortNode__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle__MergeSortNode); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_128118063);
    __Pyx_GIVEREF(__pyx_int_128118063);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_128118063);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_state);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
    __pyx_t_6 = 0;
    __pyx_t_8 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__MergeSortNode__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_6__setstate_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_14_MergeSortNode_6__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__MergeSortNode__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSortNode__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__MergeSortNode, (type(self), 0x7a2ed2f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__MergeSortNode__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSortNode.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":750
 *     cdef object _scheduled_nodes # List of nodes ready to be yielded
 * 
 *     def __init__(self, known_graph, tip_key):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 * 
 */

/* Python wrapper */
static int __pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_known_graph = 0;
  PyObject *__pyx_v_tip_key = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_known_graph,&__pyx_n_s_tip_key,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_known_graph)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tip_key)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 750, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 750, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_known_graph = values[0];
    __pyx_v_tip_key = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 750, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter___init__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self), __pyx_v_known_graph, __pyx_v_tip_key);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter___init__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, PyObject *__pyx_v_known_graph, PyObject *__pyx_v_tip_key) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "breezy/_known_graph_pyx.pyx":753
 *         cdef _KnownGraphNode node
 * 
 *         self.graph = known_graph             # <<<<<<<<<<<<<<
 *         # self._ms_nodes = {}
 *         self._revno_to_branch_count = {}
 */
  if (!(likely(((__pyx_v_known_graph) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_known_graph, __pyx_ptype_6breezy_16_known_graph_pyx_KnownGraph))))) __PYX_ERR(0, 753, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_known_graph;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->graph);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->graph));
  __pyx_v_self->graph = ((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":755
 *         self.graph = known_graph
 *         # self._ms_nodes = {}
 *         self._revno_to_branch_count = {}             # <<<<<<<<<<<<<<
 *         self._depth_first_stack = []
 *         self._last_stack_item = -1
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_revno_to_branch_count);
  __Pyx_DECREF(__pyx_v_self->_revno_to_branch_count);
  __pyx_v_self->_revno_to_branch_count = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":756
 *         # self._ms_nodes = {}
 *         self._revno_to_branch_count = {}
 *         self._depth_first_stack = []             # <<<<<<<<<<<<<<
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_depth_first_stack);
  __Pyx_DECREF(__pyx_v_self->_depth_first_stack);
  __pyx_v_self->_depth_first_stack = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":757
 *         self._revno_to_branch_count = {}
 *         self._depth_first_stack = []
 *         self._last_stack_item = -1             # <<<<<<<<<<<<<<
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION
 */
  __pyx_v_self->_last_stack_item = -1L;

  /* "breezy/_known_graph_pyx.pyx":758
 *         self._depth_first_stack = []
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []             # <<<<<<<<<<<<<<
 *         if (tip_key is not None and tip_key != NULL_REVISION
 *             and tip_key != (NULL_REVISION,)):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_scheduled_nodes);
  __Pyx_DECREF(__pyx_v_self->_scheduled_nodes);
  __pyx_v_self->_scheduled_nodes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":759
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION             # <<<<<<<<<<<<<<
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]
 */
  __pyx_t_3 = (__pyx_v_tip_key != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "breezy/_known_graph_pyx.pyx":760
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION
 *             and tip_key != (NULL_REVISION,)):             # <<<<<<<<<<<<<<
 *             node = self.graph._nodes[tip_key]
 *             self._push_node(node, 0)
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_tip_key, __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error)

  /* "breezy/_known_graph_pyx.pyx":759
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION             # <<<<<<<<<<<<<<
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "breezy/_known_graph_pyx.pyx":760
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION
 *             and tip_key != (NULL_REVISION,)):             # <<<<<<<<<<<<<<
 *             node = self.graph._nodes[tip_key]
 *             self._push_node(node, 0)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
  __Pyx_GIVEREF(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_tip_key, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;

  /* "breezy/_known_graph_pyx.pyx":759
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION             # <<<<<<<<<<<<<<
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]
 */
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":761
 *         if (tip_key is not None and tip_key != NULL_REVISION
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]             # <<<<<<<<<<<<<<
 *             self._push_node(node, 0)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_self->graph->_nodes, __pyx_v_tip_key); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 761, __pyx_L1_error)
    __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":762
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]
 *             self._push_node(node, 0)             # <<<<<<<<<<<<<<
 * 
 *     cdef _MergeSortNode _get_ms_node(self, _KnownGraphNode node):
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_push_node(__pyx_v_self, __pyx_v_node, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "breezy/_known_graph_pyx.pyx":759
 *         self._last_stack_item = -1
 *         self._scheduled_nodes = []
 *         if (tip_key is not None and tip_key != NULL_REVISION             # <<<<<<<<<<<<<<
 *             and tip_key != (NULL_REVISION,)):
 *             node = self.graph._nodes[tip_key]
 */
  }

  /* "breezy/_known_graph_pyx.pyx":750
 *     cdef object _scheduled_nodes # List of nodes ready to be yielded
 * 
 *     def __init__(self, known_graph, tip_key):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode node
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":764
 *             self._push_node(node, 0)
 * 
 *     cdef _MergeSortNode _get_ms_node(self, _KnownGraphNode node):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _MergeSortNode ms_node
 */

static struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__get_ms_node(CYTHON_UNUSED struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_get_ms_node", 0);

  /* "breezy/_known_graph_pyx.pyx":768
 *         cdef _MergeSortNode ms_node
 * 
 *         if node.extra is None:             # <<<<<<<<<<<<<<
 *             ms_node = _MergeSortNode(node.key)
 *             node.extra = ms_node
 */
  __pyx_t_1 = (__pyx_v_node->extra == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":769
 * 
 *         if node.extra is None:
 *             ms_node = _MergeSortNode(node.key)             # <<<<<<<<<<<<<<
 *             node.extra = ms_node
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__MergeSortNode), __pyx_v_node->key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ms_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":770
 *         if node.extra is None:
 *             ms_node = _MergeSortNode(node.key)
 *             node.extra = ms_node             # <<<<<<<<<<<<<<
 *         else:
 *             ms_node = <_MergeSortNode>node.extra
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_ms_node));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ms_node));
    __Pyx_GOTREF(__pyx_v_node->extra);
    __Pyx_DECREF(__pyx_v_node->extra);
    __pyx_v_node->extra = ((PyObject *)__pyx_v_ms_node);

    /* "breezy/_known_graph_pyx.pyx":768
 *         cdef _MergeSortNode ms_node
 * 
 *         if node.extra is None:             # <<<<<<<<<<<<<<
 *             ms_node = _MergeSortNode(node.key)
 *             node.extra = ms_node
 */
    goto __pyx_L3;
  }

  /* "breezy/_known_graph_pyx.pyx":772
 *             node.extra = ms_node
 *         else:
 *             ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 *         return ms_node
 * 
 */
  /*else*/ {
    __pyx_t_3 = __pyx_v_node->extra;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_ms_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "breezy/_known_graph_pyx.pyx":773
 *         else:
 *             ms_node = <_MergeSortNode>node.extra
 *         return ms_node             # <<<<<<<<<<<<<<
 * 
 *     cdef _push_node(self, _KnownGraphNode node, long merge_depth):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ms_node));
  __pyx_r = __pyx_v_ms_node;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":764
 *             self._push_node(node, 0)
 * 
 *     cdef _MergeSortNode _get_ms_node(self, _KnownGraphNode node):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp_node
 *         cdef _MergeSortNode ms_node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter._get_ms_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_node);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":775
 *         return ms_node
 * 
 *     cdef _push_node(self, _KnownGraphNode node, long merge_depth):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode parent_node
 *         cdef _MergeSortNode ms_node, ms_parent_node
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__push_node(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, long __pyx_v_merge_depth) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_parent_node = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_push_node", 0);

  /* "breezy/_known_graph_pyx.pyx":780
 *         cdef Py_ssize_t pos
 * 
 *         ms_node = self._get_ms_node(node)             # <<<<<<<<<<<<<<
 *         ms_node.merge_depth = merge_depth
 *         if node.parents is None:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, __pyx_v_node)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ms_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":781
 * 
 *         ms_node = self._get_ms_node(node)
 *         ms_node.merge_depth = merge_depth             # <<<<<<<<<<<<<<
 *         if node.parents is None:
 *             raise RuntimeError('ghost nodes should not be pushed'
 */
  __pyx_v_ms_node->merge_depth = __pyx_v_merge_depth;

  /* "breezy/_known_graph_pyx.pyx":782
 *         ms_node = self._get_ms_node(node)
 *         ms_node.merge_depth = merge_depth
 *         if node.parents is None:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('ghost nodes should not be pushed'
 *                                ' onto the stack: %s' % (node,))
 */
  __pyx_t_2 = (__pyx_v_node->parents == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "breezy/_known_graph_pyx.pyx":784
 *         if node.parents is None:
 *             raise RuntimeError('ghost nodes should not be pushed'
 *                                ' onto the stack: %s' % (node,))             # <<<<<<<<<<<<<<
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 *             parent_node = _get_tuple_node(node.parents, 0)
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_node));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_node));
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_ghost_nodes_should_not_be_pushed, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "breezy/_known_graph_pyx.pyx":783
 *         ms_node.merge_depth = merge_depth
 *         if node.parents is None:
 *             raise RuntimeError('ghost nodes should not be pushed'             # <<<<<<<<<<<<<<
 *                                ' onto the stack: %s' % (node,))
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 783, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":782
 *         ms_node = self._get_ms_node(node)
 *         ms_node.merge_depth = merge_depth
 *         if node.parents is None:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('ghost nodes should not be pushed'
 *                                ' onto the stack: %s' % (node,))
 */
  }

  /* "breezy/_known_graph_pyx.pyx":785
 *             raise RuntimeError('ghost nodes should not be pushed'
 *                                ' onto the stack: %s' % (node,))
 *         if PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 *             parent_node = _get_tuple_node(node.parents, 0)
 *             ms_node.left_parent = parent_node
 */
  __pyx_t_1 = __pyx_v_node->parents;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = ((PyTuple_GET_SIZE(__pyx_t_1) > 0) != 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "breezy/_known_graph_pyx.pyx":786
 *                                ' onto the stack: %s' % (node,))
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 *             parent_node = _get_tuple_node(node.parents, 0)             # <<<<<<<<<<<<<<
 *             ms_node.left_parent = parent_node
 *             if parent_node.parents is None: # left-hand ghost
 */
    __pyx_t_1 = __pyx_v_node->parents;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_t_1, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_parent_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":787
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 *             parent_node = _get_tuple_node(node.parents, 0)
 *             ms_node.left_parent = parent_node             # <<<<<<<<<<<<<<
 *             if parent_node.parents is None: # left-hand ghost
 *                 ms_node.left_pending_parent = None
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_parent_node));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_node));
    __Pyx_GOTREF(__pyx_v_ms_node->left_parent);
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_parent));
    __pyx_v_ms_node->left_parent = __pyx_v_parent_node;

    /* "breezy/_known_graph_pyx.pyx":788
 *             parent_node = _get_tuple_node(node.parents, 0)
 *             ms_node.left_parent = parent_node
 *             if parent_node.parents is None: # left-hand ghost             # <<<<<<<<<<<<<<
 *                 ms_node.left_pending_parent = None
 *                 ms_node.left_parent = None
 */
    __pyx_t_3 = (__pyx_v_parent_node->parents == Py_None);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":789
 *             ms_node.left_parent = parent_node
 *             if parent_node.parents is None: # left-hand ghost
 *                 ms_node.left_pending_parent = None             # <<<<<<<<<<<<<<
 *                 ms_node.left_parent = None
 *             else:
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_ms_node->left_pending_parent);
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_pending_parent));
      __pyx_v_ms_node->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None);

      /* "breezy/_known_graph_pyx.pyx":790
 *             if parent_node.parents is None: # left-hand ghost
 *                 ms_node.left_pending_parent = None
 *                 ms_node.left_parent = None             # <<<<<<<<<<<<<<
 *             else:
 *                 ms_node.left_pending_parent = parent_node
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_ms_node->left_parent);
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_parent));
      __pyx_v_ms_node->left_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None);

      /* "breezy/_known_graph_pyx.pyx":788
 *             parent_node = _get_tuple_node(node.parents, 0)
 *             ms_node.left_parent = parent_node
 *             if parent_node.parents is None: # left-hand ghost             # <<<<<<<<<<<<<<
 *                 ms_node.left_pending_parent = None
 *                 ms_node.left_parent = None
 */
      goto __pyx_L5;
    }

    /* "breezy/_known_graph_pyx.pyx":792
 *                 ms_node.left_parent = None
 *             else:
 *                 ms_node.left_pending_parent = parent_node             # <<<<<<<<<<<<<<
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 *             ms_node.pending_parents = []
 */
    /*else*/ {
      __Pyx_INCREF(((PyObject *)__pyx_v_parent_node));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_node));
      __Pyx_GOTREF(__pyx_v_ms_node->left_pending_parent);
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_pending_parent));
      __pyx_v_ms_node->left_pending_parent = __pyx_v_parent_node;
    }
    __pyx_L5:;

    /* "breezy/_known_graph_pyx.pyx":785
 *             raise RuntimeError('ghost nodes should not be pushed'
 *                                ' onto the stack: %s' % (node,))
 *         if PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 *             parent_node = _get_tuple_node(node.parents, 0)
 *             ms_node.left_parent = parent_node
 */
  }

  /* "breezy/_known_graph_pyx.pyx":793
 *             else:
 *                 ms_node.left_pending_parent = parent_node
 *         if PyTuple_GET_SIZE(node.parents) > 1:             # <<<<<<<<<<<<<<
 *             ms_node.pending_parents = []
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 */
  __pyx_t_4 = __pyx_v_node->parents;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = ((PyTuple_GET_SIZE(__pyx_t_4) > 1) != 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":794
 *                 ms_node.left_pending_parent = parent_node
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 *             ms_node.pending_parents = []             # <<<<<<<<<<<<<<
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 *                 parent_node = _get_tuple_node(node.parents, pos)
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_ms_node->pending_parents);
    __Pyx_DECREF(__pyx_v_ms_node->pending_parents);
    __pyx_v_ms_node->pending_parents = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":795
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 *             ms_node.pending_parents = []
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):             # <<<<<<<<<<<<<<
 *                 parent_node = _get_tuple_node(node.parents, pos)
 *                 if parent_node.parents is None: # ghost
 */
    __pyx_t_4 = __pyx_v_node->parents;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_GET_SIZE(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (__pyx_v_pos = 1; __pyx_v_pos < __pyx_t_5; __pyx_v_pos++) {

      /* "breezy/_known_graph_pyx.pyx":796
 *             ms_node.pending_parents = []
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 *                 parent_node = _get_tuple_node(node.parents, pos)             # <<<<<<<<<<<<<<
 *                 if parent_node.parents is None: # ghost
 *                     continue
 */
      __pyx_t_4 = __pyx_v_node->parents;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_tuple_node(__pyx_t_4, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_parent_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":797
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 *                 parent_node = _get_tuple_node(node.parents, pos)
 *                 if parent_node.parents is None: # ghost             # <<<<<<<<<<<<<<
 *                     continue
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 */
      __pyx_t_2 = (__pyx_v_parent_node->parents == Py_None);
      __pyx_t_3 = (__pyx_t_2 != 0);
      if (__pyx_t_3) {

        /* "breezy/_known_graph_pyx.pyx":798
 *                 parent_node = _get_tuple_node(node.parents, pos)
 *                 if parent_node.parents is None: # ghost
 *                     continue             # <<<<<<<<<<<<<<
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 * 
 */
        goto __pyx_L7_continue;

        /* "breezy/_known_graph_pyx.pyx":797
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 *                 parent_node = _get_tuple_node(node.parents, pos)
 *                 if parent_node.parents is None: # ghost             # <<<<<<<<<<<<<<
 *                     continue
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 */
      }

      /* "breezy/_known_graph_pyx.pyx":799
 *                 if parent_node.parents is None: # ghost
 *                     continue
 *                 PyList_Append(ms_node.pending_parents, parent_node)             # <<<<<<<<<<<<<<
 * 
 *         ms_node.is_first_child = 1
 */
      __pyx_t_1 = __pyx_v_ms_node->pending_parents;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = PyList_Append(__pyx_t_1, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_L7_continue:;
    }

    /* "breezy/_known_graph_pyx.pyx":793
 *             else:
 *                 ms_node.left_pending_parent = parent_node
 *         if PyTuple_GET_SIZE(node.parents) > 1:             # <<<<<<<<<<<<<<
 *             ms_node.pending_parents = []
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 */
  }

  /* "breezy/_known_graph_pyx.pyx":801
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 * 
 *         ms_node.is_first_child = 1             # <<<<<<<<<<<<<<
 *         if ms_node.left_parent is not None:
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 */
  __pyx_v_ms_node->is_first_child = 1;

  /* "breezy/_known_graph_pyx.pyx":802
 * 
 *         ms_node.is_first_child = 1
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 *             if ms_parent_node.seen_by_child:
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_ms_node->left_parent) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":803
 *         ms_node.is_first_child = 1
 *         if ms_node.left_parent is not None:
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)             # <<<<<<<<<<<<<<
 *             if ms_parent_node.seen_by_child:
 *                 ms_node.is_first_child = 0
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_ms_node->left_parent);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ms_parent_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":804
 *         if ms_node.left_parent is not None:
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 *             if ms_parent_node.seen_by_child:             # <<<<<<<<<<<<<<
 *                 ms_node.is_first_child = 0
 *             ms_parent_node.seen_by_child = 1
 */
    __pyx_t_2 = (__pyx_v_ms_parent_node->seen_by_child != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":805
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 *             if ms_parent_node.seen_by_child:
 *                 ms_node.is_first_child = 0             # <<<<<<<<<<<<<<
 *             ms_parent_node.seen_by_child = 1
 *         self._last_stack_item = self._last_stack_item + 1
 */
      __pyx_v_ms_node->is_first_child = 0;

      /* "breezy/_known_graph_pyx.pyx":804
 *         if ms_node.left_parent is not None:
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 *             if ms_parent_node.seen_by_child:             # <<<<<<<<<<<<<<
 *                 ms_node.is_first_child = 0
 *             ms_parent_node.seen_by_child = 1
 */
    }

    /* "breezy/_known_graph_pyx.pyx":806
 *             if ms_parent_node.seen_by_child:
 *                 ms_node.is_first_child = 0
 *             ms_parent_node.seen_by_child = 1             # <<<<<<<<<<<<<<
 *         self._last_stack_item = self._last_stack_item + 1
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 */
    __pyx_v_ms_parent_node->seen_by_child = 1;

    /* "breezy/_known_graph_pyx.pyx":802
 * 
 *         ms_node.is_first_child = 1
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 *             if ms_parent_node.seen_by_child:
 */
  }

  /* "breezy/_known_graph_pyx.pyx":807
 *                 ms_node.is_first_child = 0
 *             ms_parent_node.seen_by_child = 1
 *         self._last_stack_item = self._last_stack_item + 1             # <<<<<<<<<<<<<<
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 *             Py_INCREF(node) # SetItem steals a ref
 */
  __pyx_v_self->_last_stack_item = (__pyx_v_self->_last_stack_item + 1);

  /* "breezy/_known_graph_pyx.pyx":808
 *             ms_parent_node.seen_by_child = 1
 *         self._last_stack_item = self._last_stack_item + 1
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):             # <<<<<<<<<<<<<<
 *             Py_INCREF(node) # SetItem steals a ref
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 */
  __pyx_t_4 = __pyx_v_self->_depth_first_stack;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = ((__pyx_v_self->_last_stack_item < PyList_GET_SIZE(__pyx_t_4)) != 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "breezy/_known_graph_pyx.pyx":809
 *         self._last_stack_item = self._last_stack_item + 1
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 *             Py_INCREF(node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 *                            node)
 */
    Py_INCREF(((PyObject *)__pyx_v_node));

    /* "breezy/_known_graph_pyx.pyx":810
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 *             Py_INCREF(node) # SetItem steals a ref
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,             # <<<<<<<<<<<<<<
 *                            node)
 *         else:
 */
    __pyx_t_4 = __pyx_v_self->_depth_first_stack;
    __Pyx_INCREF(__pyx_t_4);

    /* "breezy/_known_graph_pyx.pyx":811
 *             Py_INCREF(node) # SetItem steals a ref
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 *                            node)             # <<<<<<<<<<<<<<
 *         else:
 *             PyList_Append(self._depth_first_stack, node)
 */
    __pyx_t_6 = PyList_SetItem(__pyx_t_4, __pyx_v_self->_last_stack_item, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 810, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "breezy/_known_graph_pyx.pyx":808
 *             ms_parent_node.seen_by_child = 1
 *         self._last_stack_item = self._last_stack_item + 1
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):             # <<<<<<<<<<<<<<
 *             Py_INCREF(node) # SetItem steals a ref
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 */
    goto __pyx_L12;
  }

  /* "breezy/_known_graph_pyx.pyx":813
 *                            node)
 *         else:
 *             PyList_Append(self._depth_first_stack, node)             # <<<<<<<<<<<<<<
 * 
 *     cdef _pop_node(self):
 */
  /*else*/ {
    __pyx_t_4 = __pyx_v_self->_depth_first_stack;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = PyList_Append(__pyx_t_4, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 813, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L12:;

  /* "breezy/_known_graph_pyx.pyx":775
 *         return ms_node
 * 
 *     cdef _push_node(self, _KnownGraphNode node, long merge_depth):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode parent_node
 *         cdef _MergeSortNode ms_node, ms_parent_node
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter._push_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_parent_node);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":815
 *             PyList_Append(self._depth_first_stack, node)
 * 
 *     cdef _pop_node(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp
 *         cdef _MergeSortNode ms_node, ms_parent_node, ms_prev_node
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__pop_node(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
  PyObject *__pyx_v_temp;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_parent_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_prev_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_prev_node = 0;
  long __pyx_v_base_revno;
  PyObject *__pyx_v_branch_count = NULL;
  PyObject *__pyx_v_root_count = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_pop_node", 0);

  /* "breezy/_known_graph_pyx.pyx":820
 *         cdef _KnownGraphNode node, parent_node, prev_node
 * 
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)             # <<<<<<<<<<<<<<
 *         ms_node = <_MergeSortNode>node.extra
 *         self._last_stack_item = self._last_stack_item - 1
 */
  __pyx_t_1 = __pyx_v_self->_depth_first_stack;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_self->_last_stack_item)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":821
 * 
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)
 *         ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 *         self._last_stack_item = self._last_stack_item - 1
 *         if ms_node.left_parent is not None:
 */
  __pyx_t_2 = __pyx_v_node->extra;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_ms_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":822
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)
 *         ms_node = <_MergeSortNode>node.extra
 *         self._last_stack_item = self._last_stack_item - 1             # <<<<<<<<<<<<<<
 *         if ms_node.left_parent is not None:
 *             # Assign the revision number from the left-hand parent
 */
  __pyx_v_self->_last_stack_item = (__pyx_v_self->_last_stack_item - 1);

  /* "breezy/_known_graph_pyx.pyx":823
 *         ms_node = <_MergeSortNode>node.extra
 *         self._last_stack_item = self._last_stack_item - 1
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 *             # Assign the revision number from the left-hand parent
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_ms_node->left_parent) != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "breezy/_known_graph_pyx.pyx":825
 *         if ms_node.left_parent is not None:
 *             # Assign the revision number from the left-hand parent
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra             # <<<<<<<<<<<<<<
 *             if ms_node.is_first_child:
 *                 # First child just increments the final digit
 */
    __pyx_t_2 = __pyx_v_ms_node->left_parent->extra;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_ms_parent_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "breezy/_known_graph_pyx.pyx":826
 *             # Assign the revision number from the left-hand parent
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 *             if ms_node.is_first_child:             # <<<<<<<<<<<<<<
 *                 # First child just increments the final digit
 *                 ms_node._revno_first = ms_parent_node._revno_first
 */
    __pyx_t_4 = (__pyx_v_ms_node->is_first_child != 0);
    if (__pyx_t_4) {

      /* "breezy/_known_graph_pyx.pyx":828
 *             if ms_node.is_first_child:
 *                 # First child just increments the final digit
 *                 ms_node._revno_first = ms_parent_node._revno_first             # <<<<<<<<<<<<<<
 *                 ms_node._revno_second = ms_parent_node._revno_second
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1
 */
      __pyx_t_5 = __pyx_v_ms_parent_node->_revno_first;
      __pyx_v_ms_node->_revno_first = __pyx_t_5;

      /* "breezy/_known_graph_pyx.pyx":829
 *                 # First child just increments the final digit
 *                 ms_node._revno_first = ms_parent_node._revno_first
 *                 ms_node._revno_second = ms_parent_node._revno_second             # <<<<<<<<<<<<<<
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1
 *             else:
 */
      __pyx_t_5 = __pyx_v_ms_parent_node->_revno_second;
      __pyx_v_ms_node->_revno_second = __pyx_t_5;

      /* "breezy/_known_graph_pyx.pyx":830
 *                 ms_node._revno_first = ms_parent_node._revno_first
 *                 ms_node._revno_second = ms_parent_node._revno_second
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1             # <<<<<<<<<<<<<<
 *             else:
 *                 # Not the first child, make a new branch
 */
      __pyx_v_ms_node->_revno_last = (__pyx_v_ms_parent_node->_revno_last + 1);

      /* "breezy/_known_graph_pyx.pyx":826
 *             # Assign the revision number from the left-hand parent
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 *             if ms_node.is_first_child:             # <<<<<<<<<<<<<<
 *                 # First child just increments the final digit
 *                 ms_node._revno_first = ms_parent_node._revno_first
 */
      goto __pyx_L4;
    }

    /* "breezy/_known_graph_pyx.pyx":834
 *                 # Not the first child, make a new branch
 *                 #  (mainline_revno, branch_count, 1)
 *                 if ms_parent_node._revno_first == -1:             # <<<<<<<<<<<<<<
 *                     # Mainline ancestor, the increment is on the last digit
 *                     base_revno = ms_parent_node._revno_last
 */
    /*else*/ {
      __pyx_t_4 = ((__pyx_v_ms_parent_node->_revno_first == -1L) != 0);
      if (__pyx_t_4) {

        /* "breezy/_known_graph_pyx.pyx":836
 *                 if ms_parent_node._revno_first == -1:
 *                     # Mainline ancestor, the increment is on the last digit
 *                     base_revno = ms_parent_node._revno_last             # <<<<<<<<<<<<<<
 *                 else:
 *                     base_revno = ms_parent_node._revno_first
 */
        __pyx_t_5 = __pyx_v_ms_parent_node->_revno_last;
        __pyx_v_base_revno = __pyx_t_5;

        /* "breezy/_known_graph_pyx.pyx":834
 *                 # Not the first child, make a new branch
 *                 #  (mainline_revno, branch_count, 1)
 *                 if ms_parent_node._revno_first == -1:             # <<<<<<<<<<<<<<
 *                     # Mainline ancestor, the increment is on the last digit
 *                     base_revno = ms_parent_node._revno_last
 */
        goto __pyx_L5;
      }

      /* "breezy/_known_graph_pyx.pyx":838
 *                     base_revno = ms_parent_node._revno_last
 *                 else:
 *                     base_revno = ms_parent_node._revno_first             # <<<<<<<<<<<<<<
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 *                                       base_revno)
 */
      /*else*/ {
        __pyx_t_5 = __pyx_v_ms_parent_node->_revno_first;
        __pyx_v_base_revno = __pyx_t_5;
      }
      __pyx_L5:;

      /* "breezy/_known_graph_pyx.pyx":839
 *                 else:
 *                     base_revno = ms_parent_node._revno_first
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,             # <<<<<<<<<<<<<<
 *                                       base_revno)
 *                 if temp == NULL:
 */
      __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
      __Pyx_INCREF(__pyx_t_2);

      /* "breezy/_known_graph_pyx.pyx":840
 *                     base_revno = ms_parent_node._revno_first
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 *                                       base_revno)             # <<<<<<<<<<<<<<
 *                 if temp == NULL:
 *                     branch_count = 1
 */
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_base_revno); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "breezy/_known_graph_pyx.pyx":839
 *                 else:
 *                     base_revno = ms_parent_node._revno_first
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,             # <<<<<<<<<<<<<<
 *                                       base_revno)
 *                 if temp == NULL:
 */
      __pyx_v_temp = PyDict_GetItem(__pyx_t_2, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "breezy/_known_graph_pyx.pyx":841
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 *                                       base_revno)
 *                 if temp == NULL:             # <<<<<<<<<<<<<<
 *                     branch_count = 1
 *                 else:
 */
      __pyx_t_4 = ((__pyx_v_temp == NULL) != 0);
      if (__pyx_t_4) {

        /* "breezy/_known_graph_pyx.pyx":842
 *                                       base_revno)
 *                 if temp == NULL:
 *                     branch_count = 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     branch_count = (<object>temp) + 1
 */
        __Pyx_INCREF(__pyx_int_1);
        __pyx_v_branch_count = __pyx_int_1;

        /* "breezy/_known_graph_pyx.pyx":841
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 *                                       base_revno)
 *                 if temp == NULL:             # <<<<<<<<<<<<<<
 *                     branch_count = 1
 *                 else:
 */
        goto __pyx_L6;
      }

      /* "breezy/_known_graph_pyx.pyx":844
 *                     branch_count = 1
 *                 else:
 *                     branch_count = (<object>temp) + 1             # <<<<<<<<<<<<<<
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 *                                branch_count)
 */
      /*else*/ {
        __pyx_t_1 = __Pyx_PyInt_AddObjC(((PyObject *)__pyx_v_temp), __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_branch_count = __pyx_t_1;
        __pyx_t_1 = 0;
      }
      __pyx_L6:;

      /* "breezy/_known_graph_pyx.pyx":845
 *                 else:
 *                     branch_count = (<object>temp) + 1
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,             # <<<<<<<<<<<<<<
 *                                branch_count)
 *                 ms_node._revno_first = base_revno
 */
      __pyx_t_1 = __pyx_v_self->_revno_to_branch_count;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_base_revno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 845, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "breezy/_known_graph_pyx.pyx":846
 *                     branch_count = (<object>temp) + 1
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 *                                branch_count)             # <<<<<<<<<<<<<<
 *                 ms_node._revno_first = base_revno
 *                 ms_node._revno_second = branch_count
 */
      __pyx_t_6 = PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_v_branch_count); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 845, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "breezy/_known_graph_pyx.pyx":847
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 *                                branch_count)
 *                 ms_node._revno_first = base_revno             # <<<<<<<<<<<<<<
 *                 ms_node._revno_second = branch_count
 *                 ms_node._revno_last = 1
 */
      __pyx_v_ms_node->_revno_first = __pyx_v_base_revno;

      /* "breezy/_known_graph_pyx.pyx":848
 *                                branch_count)
 *                 ms_node._revno_first = base_revno
 *                 ms_node._revno_second = branch_count             # <<<<<<<<<<<<<<
 *                 ms_node._revno_last = 1
 *         else:
 */
      __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_branch_count); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 848, __pyx_L1_error)
      __pyx_v_ms_node->_revno_second = __pyx_t_5;

      /* "breezy/_known_graph_pyx.pyx":849
 *                 ms_node._revno_first = base_revno
 *                 ms_node._revno_second = branch_count
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 *         else:
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)
 */
      __pyx_v_ms_node->_revno_last = 1;
    }
    __pyx_L4:;

    /* "breezy/_known_graph_pyx.pyx":823
 *         ms_node = <_MergeSortNode>node.extra
 *         self._last_stack_item = self._last_stack_item - 1
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 *             # Assign the revision number from the left-hand parent
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 */
    goto __pyx_L3;
  }

  /* "breezy/_known_graph_pyx.pyx":851
 *                 ms_node._revno_last = 1
 *         else:
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)             # <<<<<<<<<<<<<<
 *             if temp == NULL:
 *                 # The first root node doesn't have a 3-digit revno
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_temp = PyDict_GetItem(__pyx_t_2, __pyx_int_0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "breezy/_known_graph_pyx.pyx":852
 *         else:
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 *                 # The first root node doesn't have a 3-digit revno
 *                 root_count = 0
 */
    __pyx_t_4 = ((__pyx_v_temp == NULL) != 0);
    if (__pyx_t_4) {

      /* "breezy/_known_graph_pyx.pyx":854
 *             if temp == NULL:
 *                 # The first root node doesn't have a 3-digit revno
 *                 root_count = 0             # <<<<<<<<<<<<<<
 *                 ms_node._revno_first = -1
 *                 ms_node._revno_second = -1
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_v_root_count = __pyx_int_0;

      /* "breezy/_known_graph_pyx.pyx":855
 *                 # The first root node doesn't have a 3-digit revno
 *                 root_count = 0
 *                 ms_node._revno_first = -1             # <<<<<<<<<<<<<<
 *                 ms_node._revno_second = -1
 *                 ms_node._revno_last = 1
 */
      __pyx_v_ms_node->_revno_first = -1L;

      /* "breezy/_known_graph_pyx.pyx":856
 *                 root_count = 0
 *                 ms_node._revno_first = -1
 *                 ms_node._revno_second = -1             # <<<<<<<<<<<<<<
 *                 ms_node._revno_last = 1
 *             else:
 */
      __pyx_v_ms_node->_revno_second = -1L;

      /* "breezy/_known_graph_pyx.pyx":857
 *                 ms_node._revno_first = -1
 *                 ms_node._revno_second = -1
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 root_count = (<object>temp) + 1
 */
      __pyx_v_ms_node->_revno_last = 1;

      /* "breezy/_known_graph_pyx.pyx":852
 *         else:
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 *                 # The first root node doesn't have a 3-digit revno
 *                 root_count = 0
 */
      goto __pyx_L7;
    }

    /* "breezy/_known_graph_pyx.pyx":859
 *                 ms_node._revno_last = 1
 *             else:
 *                 root_count = (<object>temp) + 1             # <<<<<<<<<<<<<<
 *                 ms_node._revno_first = 0
 *                 ms_node._revno_second = root_count
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_PyInt_AddObjC(((PyObject *)__pyx_v_temp), __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 859, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_root_count = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "breezy/_known_graph_pyx.pyx":860
 *             else:
 *                 root_count = (<object>temp) + 1
 *                 ms_node._revno_first = 0             # <<<<<<<<<<<<<<
 *                 ms_node._revno_second = root_count
 *                 ms_node._revno_last = 1
 */
      __pyx_v_ms_node->_revno_first = 0;

      /* "breezy/_known_graph_pyx.pyx":861
 *                 root_count = (<object>temp) + 1
 *                 ms_node._revno_first = 0
 *                 ms_node._revno_second = root_count             # <<<<<<<<<<<<<<
 *                 ms_node._revno_last = 1
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 */
      __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_root_count); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 861, __pyx_L1_error)
      __pyx_v_ms_node->_revno_second = __pyx_t_5;

      /* "breezy/_known_graph_pyx.pyx":862
 *                 ms_node._revno_first = 0
 *                 ms_node._revno_second = root_count
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 *         ms_node.completed = 1
 */
      __pyx_v_ms_node->_revno_last = 1;
    }
    __pyx_L7:;

    /* "breezy/_known_graph_pyx.pyx":863
 *                 ms_node._revno_second = root_count
 *                 ms_node._revno_last = 1
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)             # <<<<<<<<<<<<<<
 *         ms_node.completed = 1
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 */
    __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = PyDict_SetItem(__pyx_t_2, __pyx_int_0, __pyx_v_root_count); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 863, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "breezy/_known_graph_pyx.pyx":864
 *                 ms_node._revno_last = 1
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 *         ms_node.completed = 1             # <<<<<<<<<<<<<<
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 *             # The first scheduled node is always the end of merge
 */
  __pyx_v_ms_node->completed = 1;

  /* "breezy/_known_graph_pyx.pyx":865
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 *         ms_node.completed = 1
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:             # <<<<<<<<<<<<<<
 *             # The first scheduled node is always the end of merge
 *             ms_node.end_of_merge = True
 */
  __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = ((PyList_GET_SIZE(__pyx_t_2) == 0) != 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "breezy/_known_graph_pyx.pyx":867
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 *             # The first scheduled node is always the end of merge
 *             ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 *         else:
 *             prev_node = _get_list_node(self._scheduled_nodes,
 */
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
    __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
    __pyx_v_ms_node->end_of_merge = Py_True;

    /* "breezy/_known_graph_pyx.pyx":865
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 *         ms_node.completed = 1
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:             # <<<<<<<<<<<<<<
 *             # The first scheduled node is always the end of merge
 *             ms_node.end_of_merge = True
 */
    goto __pyx_L8;
  }

  /* "breezy/_known_graph_pyx.pyx":869
 *             ms_node.end_of_merge = True
 *         else:
 *             prev_node = _get_list_node(self._scheduled_nodes,             # <<<<<<<<<<<<<<
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
    __Pyx_INCREF(__pyx_t_2);

    /* "breezy/_known_graph_pyx.pyx":870
 *         else:
 *             prev_node = _get_list_node(self._scheduled_nodes,
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)             # <<<<<<<<<<<<<<
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:
 */
    __pyx_t_1 = __pyx_v_self->_scheduled_nodes;
    __Pyx_INCREF(__pyx_t_1);

    /* "breezy/_known_graph_pyx.pyx":869
 *             ms_node.end_of_merge = True
 *         else:
 *             prev_node = _get_list_node(self._scheduled_nodes,             # <<<<<<<<<<<<<<
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 */
    __pyx_t_7 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_2, (PyList_GET_SIZE(__pyx_t_1) - 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 869, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_prev_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "breezy/_known_graph_pyx.pyx":871
 *             prev_node = _get_list_node(self._scheduled_nodes,
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 *             ms_prev_node = <_MergeSortNode>prev_node.extra             # <<<<<<<<<<<<<<
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:
 *                 # The previously pushed node is to our left, so this is the end
 */
    __pyx_t_7 = __pyx_v_prev_node->extra;
    __Pyx_INCREF(__pyx_t_7);
    __pyx_v_ms_prev_node = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "breezy/_known_graph_pyx.pyx":872
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:             # <<<<<<<<<<<<<<
 *                 # The previously pushed node is to our left, so this is the end
 *                 # of this right-hand chain
 */
    __pyx_t_4 = ((__pyx_v_ms_prev_node->merge_depth < __pyx_v_ms_node->merge_depth) != 0);
    if (__pyx_t_4) {

      /* "breezy/_known_graph_pyx.pyx":875
 *                 # The previously pushed node is to our left, so this is the end
 *                 # of this right-hand chain
 *                 ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth
 *                   and prev_node not in node.parents):
 */
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
      __pyx_v_ms_node->end_of_merge = Py_True;

      /* "breezy/_known_graph_pyx.pyx":872
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:             # <<<<<<<<<<<<<<
 *                 # The previously pushed node is to our left, so this is the end
 *                 # of this right-hand chain
 */
      goto __pyx_L9;
    }

    /* "breezy/_known_graph_pyx.pyx":876
 *                 # of this right-hand chain
 *                 ms_node.end_of_merge = True
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth             # <<<<<<<<<<<<<<
 *                   and prev_node not in node.parents):
 *                 # The next node is not a direct parent of this node
 */
    __pyx_t_3 = ((__pyx_v_ms_prev_node->merge_depth == __pyx_v_ms_node->merge_depth) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L10_bool_binop_done;
    }

    /* "breezy/_known_graph_pyx.pyx":877
 *                 ms_node.end_of_merge = True
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth
 *                   and prev_node not in node.parents):             # <<<<<<<<<<<<<<
 *                 # The next node is not a direct parent of this node
 *                 ms_node.end_of_merge = True
 */
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(((PyObject *)__pyx_v_prev_node), __pyx_v_node->parents, Py_NE)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 877, __pyx_L1_error)
    __pyx_t_8 = (__pyx_t_3 != 0);
    __pyx_t_4 = __pyx_t_8;
    __pyx_L10_bool_binop_done:;

    /* "breezy/_known_graph_pyx.pyx":876
 *                 # of this right-hand chain
 *                 ms_node.end_of_merge = True
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth             # <<<<<<<<<<<<<<
 *                   and prev_node not in node.parents):
 *                 # The next node is not a direct parent of this node
 */
    if (__pyx_t_4) {

      /* "breezy/_known_graph_pyx.pyx":879
 *                   and prev_node not in node.parents):
 *                 # The next node is not a direct parent of this node
 *                 ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 *             else:
 *                 ms_node.end_of_merge = False
 */
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
      __pyx_v_ms_node->end_of_merge = Py_True;

      /* "breezy/_known_graph_pyx.pyx":876
 *                 # of this right-hand chain
 *                 ms_node.end_of_merge = True
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth             # <<<<<<<<<<<<<<
 *                   and prev_node not in node.parents):
 *                 # The next node is not a direct parent of this node
 */
      goto __pyx_L9;
    }

    /* "breezy/_known_graph_pyx.pyx":881
 *                 ms_node.end_of_merge = True
 *             else:
 *                 ms_node.end_of_merge = False             # <<<<<<<<<<<<<<
 *         PyList_Append(self._scheduled_nodes, node)
 * 
 */
    /*else*/ {
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
      __pyx_v_ms_node->end_of_merge = Py_False;
    }
    __pyx_L9:;
  }
  __pyx_L8:;

  /* "breezy/_known_graph_pyx.pyx":882
 *             else:
 *                 ms_node.end_of_merge = False
 *         PyList_Append(self._scheduled_nodes, node)             # <<<<<<<<<<<<<<
 * 
 *     cdef _schedule_stack(self):
 */
  __pyx_t_7 = __pyx_v_self->_scheduled_nodes;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_6 = PyList_Append(__pyx_t_7, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 882, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "breezy/_known_graph_pyx.pyx":815
 *             PyList_Append(self._depth_first_stack, node)
 * 
 *     cdef _pop_node(self):             # <<<<<<<<<<<<<<
 *         cdef PyObject *temp
 *         cdef _MergeSortNode ms_node, ms_parent_node, ms_prev_node
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter._pop_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_parent_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_prev_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_prev_node);
  __Pyx_XDECREF(__pyx_v_branch_count);
  __Pyx_XDECREF(__pyx_v_root_count);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":884
 *         PyList_Append(self._scheduled_nodes, node)
 * 
 *     cdef _schedule_stack(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode last_node, next_node
 *         cdef _MergeSortNode ms_node, ms_last_node, ms_next_node
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__schedule_stack(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_last_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_next_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_last_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_next_node = 0;
  long __pyx_v_next_merge_depth;
  CYTHON_UNUSED PyObject *__pyx_v_ordered = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  long __pyx_t_6;
  __Pyx_RefNannySetupContext("_schedule_stack", 0);

  /* "breezy/_known_graph_pyx.pyx":888
 *         cdef _MergeSortNode ms_node, ms_last_node, ms_next_node
 *         cdef long next_merge_depth
 *         ordered = []             # <<<<<<<<<<<<<<
 *         while self._last_stack_item >= 0:
 *             # Peek at the last item on the stack
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ordered = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":889
 *         cdef long next_merge_depth
 *         ordered = []
 *         while self._last_stack_item >= 0:             # <<<<<<<<<<<<<<
 *             # Peek at the last item on the stack
 *             last_node = _get_list_node(self._depth_first_stack,
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_self->_last_stack_item >= 0) != 0);
    if (!__pyx_t_2) break;

    /* "breezy/_known_graph_pyx.pyx":891
 *         while self._last_stack_item >= 0:
 *             # Peek at the last item on the stack
 *             last_node = _get_list_node(self._depth_first_stack,             # <<<<<<<<<<<<<<
 *                                        self._last_stack_item)
 *             if last_node.gdfo == -1:
 */
    __pyx_t_1 = __pyx_v_self->_depth_first_stack;
    __Pyx_INCREF(__pyx_t_1);

    /* "breezy/_known_graph_pyx.pyx":892
 *             # Peek at the last item on the stack
 *             last_node = _get_list_node(self._depth_first_stack,
 *                                        self._last_stack_item)             # <<<<<<<<<<<<<<
 *             if last_node.gdfo == -1:
 *                 # if _find_gdfo skipped a node, that means there is a graph
 */
    __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_self->_last_stack_item)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_last_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":893
 *             last_node = _get_list_node(self._depth_first_stack,
 *                                        self._last_stack_item)
 *             if last_node.gdfo == -1:             # <<<<<<<<<<<<<<
 *                 # if _find_gdfo skipped a node, that means there is a graph
 *                 # cycle, error out now
 */
    __pyx_t_2 = ((__pyx_v_last_node->gdfo == -1L) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "breezy/_known_graph_pyx.pyx":896
 *                 # if _find_gdfo skipped a node, that means there is a graph
 *                 # cycle, error out now
 *                 raise errors.GraphCycleError(self.graph._nodes)             # <<<<<<<<<<<<<<
 *             ms_last_node = <_MergeSortNode>last_node.extra
 *             if not ms_last_node.has_pending_parents():
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_GraphCycleError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_self->graph->_nodes) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->graph->_nodes);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 896, __pyx_L1_error)

      /* "breezy/_known_graph_pyx.pyx":893
 *             last_node = _get_list_node(self._depth_first_stack,
 *                                        self._last_stack_item)
 *             if last_node.gdfo == -1:             # <<<<<<<<<<<<<<
 *                 # if _find_gdfo skipped a node, that means there is a graph
 *                 # cycle, error out now
 */
    }

    /* "breezy/_known_graph_pyx.pyx":897
 *                 # cycle, error out now
 *                 raise errors.GraphCycleError(self.graph._nodes)
 *             ms_last_node = <_MergeSortNode>last_node.extra             # <<<<<<<<<<<<<<
 *             if not ms_last_node.has_pending_parents():
 *                 # Processed all parents, pop this node
 */
    __pyx_t_3 = __pyx_v_last_node->extra;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_ms_last_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":898
 *                 raise errors.GraphCycleError(self.graph._nodes)
 *             ms_last_node = <_MergeSortNode>last_node.extra
 *             if not ms_last_node.has_pending_parents():             # <<<<<<<<<<<<<<
 *                 # Processed all parents, pop this node
 *                 self._pop_node()
 */
    __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_last_node->__pyx_vtab)->has_pending_parents(__pyx_v_ms_last_node) != 0)) != 0);
    if (__pyx_t_2) {

      /* "breezy/_known_graph_pyx.pyx":900
 *             if not ms_last_node.has_pending_parents():
 *                 # Processed all parents, pop this node
 *                 self._pop_node()             # <<<<<<<<<<<<<<
 *                 continue
 *             while ms_last_node.has_pending_parents():
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_pop_node(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":901
 *                 # Processed all parents, pop this node
 *                 self._pop_node()
 *                 continue             # <<<<<<<<<<<<<<
 *             while ms_last_node.has_pending_parents():
 *                 if ms_last_node.left_pending_parent is not None:
 */
      goto __pyx_L3_continue;

      /* "breezy/_known_graph_pyx.pyx":898
 *                 raise errors.GraphCycleError(self.graph._nodes)
 *             ms_last_node = <_MergeSortNode>last_node.extra
 *             if not ms_last_node.has_pending_parents():             # <<<<<<<<<<<<<<
 *                 # Processed all parents, pop this node
 *                 self._pop_node()
 */
    }

    /* "breezy/_known_graph_pyx.pyx":902
 *                 self._pop_node()
 *                 continue
 *             while ms_last_node.has_pending_parents():             # <<<<<<<<<<<<<<
 *                 if ms_last_node.left_pending_parent is not None:
 *                     # recurse depth first into the primary parent
 */
    while (1) {
      __pyx_t_2 = (((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_last_node->__pyx_vtab)->has_pending_parents(__pyx_v_ms_last_node) != 0);
      if (!__pyx_t_2) break;

      /* "breezy/_known_graph_pyx.pyx":903
 *                 continue
 *             while ms_last_node.has_pending_parents():
 *                 if ms_last_node.left_pending_parent is not None:             # <<<<<<<<<<<<<<
 *                     # recurse depth first into the primary parent
 *                     next_node = ms_last_node.left_pending_parent
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_ms_last_node->left_pending_parent) != Py_None);
      __pyx_t_5 = (__pyx_t_2 != 0);
      if (__pyx_t_5) {

        /* "breezy/_known_graph_pyx.pyx":905
 *                 if ms_last_node.left_pending_parent is not None:
 *                     # recurse depth first into the primary parent
 *                     next_node = ms_last_node.left_pending_parent             # <<<<<<<<<<<<<<
 *                     ms_last_node.left_pending_parent = None
 *                 else:
 */
        __pyx_t_3 = ((PyObject *)__pyx_v_ms_last_node->left_pending_parent);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_XDECREF_SET(__pyx_v_next_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
        __pyx_t_3 = 0;

        /* "breezy/_known_graph_pyx.pyx":906
 *                     # recurse depth first into the primary parent
 *                     next_node = ms_last_node.left_pending_parent
 *                     ms_last_node.left_pending_parent = None             # <<<<<<<<<<<<<<
 *                 else:
 *                     # place any merges in right-to-left order for scheduling
 */
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        __Pyx_GOTREF(__pyx_v_ms_last_node->left_pending_parent);
        __Pyx_DECREF(((PyObject *)__pyx_v_ms_last_node->left_pending_parent));
        __pyx_v_ms_last_node->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None);

        /* "breezy/_known_graph_pyx.pyx":903
 *                 continue
 *             while ms_last_node.has_pending_parents():
 *                 if ms_last_node.left_pending_parent is not None:             # <<<<<<<<<<<<<<
 *                     # recurse depth first into the primary parent
 *                     next_node = ms_last_node.left_pending_parent
 */
        goto __pyx_L9;
      }

      /* "breezy/_known_graph_pyx.pyx":915
 *                     #       left most, which will display nicely (you get
 *                     #       smaller trees at the top of the combined merge).
 *                     next_node = ms_last_node.pending_parents.pop()             # <<<<<<<<<<<<<<
 *                 ms_next_node = self._get_ms_node(next_node)
 *                 if ms_next_node.completed:
 */
      /*else*/ {
        __pyx_t_3 = __Pyx_PyObject_Pop(__pyx_v_ms_last_node->pending_parents); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 915, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(0, 915, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_next_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
        __pyx_t_3 = 0;
      }
      __pyx_L9:;

      /* "breezy/_known_graph_pyx.pyx":916
 *                     #       smaller trees at the top of the combined merge).
 *                     next_node = ms_last_node.pending_parents.pop()
 *                 ms_next_node = self._get_ms_node(next_node)             # <<<<<<<<<<<<<<
 *                 if ms_next_node.completed:
 *                     # this parent was completed by a child on the
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, __pyx_v_next_node)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_ms_next_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":917
 *                     next_node = ms_last_node.pending_parents.pop()
 *                 ms_next_node = self._get_ms_node(next_node)
 *                 if ms_next_node.completed:             # <<<<<<<<<<<<<<
 *                     # this parent was completed by a child on the
 *                     # call stack. skip it.
 */
      __pyx_t_5 = (__pyx_v_ms_next_node->completed != 0);
      if (__pyx_t_5) {

        /* "breezy/_known_graph_pyx.pyx":920
 *                     # this parent was completed by a child on the
 *                     # call stack. skip it.
 *                     continue             # <<<<<<<<<<<<<<
 *                 # otherwise transfer it from the source graph into the
 *                 # top of the current depth first search stack.
 */
        goto __pyx_L7_continue;

        /* "breezy/_known_graph_pyx.pyx":917
 *                     next_node = ms_last_node.pending_parents.pop()
 *                 ms_next_node = self._get_ms_node(next_node)
 *                 if ms_next_node.completed:             # <<<<<<<<<<<<<<
 *                     # this parent was completed by a child on the
 *                     # call stack. skip it.
 */
      }

      /* "breezy/_known_graph_pyx.pyx":924
 *                 # top of the current depth first search stack.
 * 
 *                 if next_node is ms_last_node.left_parent:             # <<<<<<<<<<<<<<
 *                     next_merge_depth = ms_last_node.merge_depth
 *                 else:
 */
      __pyx_t_5 = (__pyx_v_next_node == __pyx_v_ms_last_node->left_parent);
      __pyx_t_2 = (__pyx_t_5 != 0);
      if (__pyx_t_2) {

        /* "breezy/_known_graph_pyx.pyx":925
 * 
 *                 if next_node is ms_last_node.left_parent:
 *                     next_merge_depth = ms_last_node.merge_depth             # <<<<<<<<<<<<<<
 *                 else:
 *                     next_merge_depth = ms_last_node.merge_depth + 1
 */
        __pyx_t_6 = __pyx_v_ms_last_node->merge_depth;
        __pyx_v_next_merge_depth = __pyx_t_6;

        /* "breezy/_known_graph_pyx.pyx":924
 *                 # top of the current depth first search stack.
 * 
 *                 if next_node is ms_last_node.left_parent:             # <<<<<<<<<<<<<<
 *                     next_merge_depth = ms_last_node.merge_depth
 *                 else:
 */
        goto __pyx_L11;
      }

      /* "breezy/_known_graph_pyx.pyx":927
 *                     next_merge_depth = ms_last_node.merge_depth
 *                 else:
 *                     next_merge_depth = ms_last_node.merge_depth + 1             # <<<<<<<<<<<<<<
 *                 self._push_node(next_node, next_merge_depth)
 *                 # and do not continue processing parents until this 'call'
 */
      /*else*/ {
        __pyx_v_next_merge_depth = (__pyx_v_ms_last_node->merge_depth + 1);
      }
      __pyx_L11:;

      /* "breezy/_known_graph_pyx.pyx":928
 *                 else:
 *                     next_merge_depth = ms_last_node.merge_depth + 1
 *                 self._push_node(next_node, next_merge_depth)             # <<<<<<<<<<<<<<
 *                 # and do not continue processing parents until this 'call'
 *                 # has recursed.
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_push_node(__pyx_v_self, __pyx_v_next_node, __pyx_v_next_merge_depth); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "breezy/_known_graph_pyx.pyx":931
 *                 # and do not continue processing parents until this 'call'
 *                 # has recursed.
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     cdef topo_order(self):
 */
      goto __pyx_L8_break;
      __pyx_L7_continue:;
    }
    __pyx_L8_break:;
    __pyx_L3_continue:;
  }

  /* "breezy/_known_graph_pyx.pyx":884
 *         PyList_Append(self._scheduled_nodes, node)
 * 
 *     cdef _schedule_stack(self):             # <<<<<<<<<<<<<<
 *         cdef _KnownGraphNode last_node, next_node
 *         cdef _MergeSortNode ms_node, ms_last_node, ms_next_node
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter._schedule_stack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_last_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_next_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_last_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_next_node);
  __Pyx_XDECREF(__pyx_v_ordered);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "breezy/_known_graph_pyx.pyx":933
 *                 break
 * 
 *     cdef topo_order(self):             # <<<<<<<<<<<<<<
 *         cdef _MergeSortNode ms_node
 *         cdef _KnownGraphNode node
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter_topo_order(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node = 0;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v_node = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_ordered = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("topo_order", 0);

  /* "breezy/_known_graph_pyx.pyx":944
 *         #       We might consider moving the attributes into the base
 *         #       KnownGraph object.
 *         self._schedule_stack()             # <<<<<<<<<<<<<<
 * 
 *         # We've set up the basic schedule, now we can continue processing the
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_schedule_stack(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":954
 *         #       7ms is computing the return tuple
 *         #       4ms is PyList_Append()
 *         ordered = []             # <<<<<<<<<<<<<<
 *         # output the result in reverse order, and separate the generated info
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ordered = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":956
 *         ordered = []
 *         # output the result in reverse order, and separate the generated info
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:             # <<<<<<<<<<<<<<
 *             node = _get_list_node(self._scheduled_nodes, pos)
 *             ms_node = <_MergeSortNode>node.extra
 */
  __pyx_t_1 = __pyx_v_self->_scheduled_nodes;
  __Pyx_INCREF(__pyx_t_1);
  for (__pyx_v_pos = PyList_GET_SIZE(__pyx_t_1)-1; __pyx_v_pos >= 0; __pyx_v_pos--) {

    /* "breezy/_known_graph_pyx.pyx":957
 *         # output the result in reverse order, and separate the generated info
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 *             node = _get_list_node(self._scheduled_nodes, pos)             # <<<<<<<<<<<<<<
 *             ms_node = <_MergeSortNode>node.extra
 *             PyList_Append(ordered, ms_node)
 */
    __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_16_known_graph_pyx__get_list_node(__pyx_t_2, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 957, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":958
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 *             node = _get_list_node(self._scheduled_nodes, pos)
 *             ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 *             PyList_Append(ordered, ms_node)
 *             node.extra = None
 */
    __pyx_t_3 = __pyx_v_node->extra;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_ms_node, ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "breezy/_known_graph_pyx.pyx":959
 *             node = _get_list_node(self._scheduled_nodes, pos)
 *             ms_node = <_MergeSortNode>node.extra
 *             PyList_Append(ordered, ms_node)             # <<<<<<<<<<<<<<
 *             node.extra = None
 *         # Clear out the scheduled nodes now that we're done
 */
    __pyx_t_4 = PyList_Append(__pyx_v_ordered, ((PyObject *)__pyx_v_ms_node)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 959, __pyx_L1_error)

    /* "breezy/_known_graph_pyx.pyx":960
 *             ms_node = <_MergeSortNode>node.extra
 *             PyList_Append(ordered, ms_node)
 *             node.extra = None             # <<<<<<<<<<<<<<
 *         # Clear out the scheduled nodes now that we're done
 *         self._scheduled_nodes = []
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_node->extra);
    __Pyx_DECREF(__pyx_v_node->extra);
    __pyx_v_node->extra = Py_None;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":962
 *             node.extra = None
 *         # Clear out the scheduled nodes now that we're done
 *         self._scheduled_nodes = []             # <<<<<<<<<<<<<<
 *         return ordered
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_scheduled_nodes);
  __Pyx_DECREF(__pyx_v_self->_scheduled_nodes);
  __pyx_v_self->_scheduled_nodes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":963
 *         # Clear out the scheduled nodes now that we're done
 *         self._scheduled_nodes = []
 *         return ordered             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ordered);
  __pyx_r = __pyx_v_ordered;
  goto __pyx_L0;

  /* "breezy/_known_graph_pyx.pyx":933
 *                 break
 * 
 *     cdef topo_order(self):             # <<<<<<<<<<<<<<
 *         cdef _MergeSortNode ms_node
 *         cdef _KnownGraphNode node
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter.topo_order", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ms_node);
  __Pyx_XDECREF((PyObject *)__pyx_v_node);
  __Pyx_XDECREF(__pyx_v_ordered);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_2__reduce_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_2__reduce_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._depth_first_stack, self._last_stack_item, self._revno_to_branch_count, self._scheduled_nodes, self.graph)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->_last_stack_item); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_depth_first_stack);
  __Pyx_GIVEREF(__pyx_v_self->_depth_first_stack);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_depth_first_stack);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_revno_to_branch_count);
  __Pyx_GIVEREF(__pyx_v_self->_revno_to_branch_count);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->_revno_to_branch_count);
  __Pyx_INCREF(__pyx_v_self->_scheduled_nodes);
  __Pyx_GIVEREF(__pyx_v_self->_scheduled_nodes);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->_scheduled_nodes);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->graph));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->graph));
  PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_v_self->graph));
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._depth_first_stack, self._last_stack_item, self._revno_to_branch_count, self._scheduled_nodes, self.graph)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self._depth_first_stack, self._last_stack_item, self._revno_to_branch_count, self._scheduled_nodes, self.graph)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._depth_first_stack is not None or self._revno_to_branch_count is not None or self._scheduled_nodes is not None or self.graph is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._depth_first_stack, self._last_stack_item, self._revno_to_branch_count, self._scheduled_nodes, self.graph)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._depth_first_stack is not None or self._revno_to_branch_count is not None or self._scheduled_nodes is not None or self.graph is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_depth_first_stack != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_revno_to_branch_count != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->_scheduled_nodes != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->graph) != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._depth_first_stack is not None or self._revno_to_branch_count is not None or self._scheduled_nodes is not None or self.graph is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self._depth_first_stack is not None or self._revno_to_branch_count is not None or self._scheduled_nodes is not None or self.graph is not None
 *     if use_setstate:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle__MergeSorter); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_116732431);
    __Pyx_GIVEREF(__pyx_int_116732431);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_116732431);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._depth_first_stack is not None or self._revno_to_branch_count is not None or self._scheduled_nodes is not None or self.graph is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, None), state
 *     else:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__MergeSorter__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle__MergeSorter); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_116732431);
    __Pyx_GIVEREF(__pyx_int_116732431);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_116732431);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__MergeSorter__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_4__setstate_cython__(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_12_MergeSorter_4__setstate_cython__(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__MergeSorter__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSorter__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__MergeSorter, (type(self), 0x6f5320f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__MergeSorter__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("breezy._known_graph_pyx._MergeSorter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle__KnownGraphNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_3__pyx_unpickle__KnownGraphNode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6breezy_16_known_graph_pyx_3__pyx_unpickle__KnownGraphNode = {"__pyx_unpickle__KnownGraphNode", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_16_known_graph_pyx_3__pyx_unpickle__KnownGraphNode, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_3__pyx_unpickle__KnownGraphNode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle__KnownGraphNode (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__KnownGraphNode", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__KnownGraphNode", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__KnownGraphNode") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__KnownGraphNode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__KnownGraphNode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_2__pyx_unpickle__KnownGraphNode(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_2__pyx_unpickle__KnownGraphNode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle__KnownGraphNode", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x1dbac4a:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x1dbac4a) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x1dbac4a:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x1dbac4a:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x1d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x1dbac4a:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__KnownGraphNode__set_state(((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x1dbac4a = (children, extra, gdfo, key, parents, seen))" % __pyx_checksum)
 *     __pyx_result = _KnownGraphNode.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__KnownGraphNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__KnownGraphNode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__KnownGraphNode__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle__KnownGraphNode__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->children);
  __Pyx_DECREF(__pyx_v___pyx_result->children);
  __pyx_v___pyx_result->children = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->extra);
  __Pyx_DECREF(__pyx_v___pyx_result->extra);
  __pyx_v___pyx_result->extra = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->gdfo = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->key);
  __Pyx_DECREF(__pyx_v___pyx_result->key);
  __pyx_v___pyx_result->key = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->parents);
  __Pyx_DECREF(__pyx_v___pyx_result->parents);
  __pyx_v___pyx_result->parents = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->seen = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 6) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":14
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__KnownGraphNode__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_KnownGraph(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_5__pyx_unpickle_KnownGraph(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6breezy_16_known_graph_pyx_5__pyx_unpickle_KnownGraph = {"__pyx_unpickle_KnownGraph", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_16_known_graph_pyx_5__pyx_unpickle_KnownGraph, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_5__pyx_unpickle_KnownGraph(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_KnownGraph (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_KnownGraph", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_KnownGraph", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_KnownGraph") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_KnownGraph", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle_KnownGraph", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_4__pyx_unpickle_KnownGraph(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_4__pyx_unpickle_KnownGraph(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_KnownGraph", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6ffbab1:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x6ffbab1) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6ffbab1:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 *     __pyx_result = KnownGraph.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x6ffbab1:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = KnownGraph.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x6f, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6ffbab1:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 *     __pyx_result = KnownGraph.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx_KnownGraph), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 *     __pyx_result = KnownGraph.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = KnownGraph.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle_KnownGraph__set_state(((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6ffbab1 = (_known_heads, _nodes, do_cache))" % __pyx_checksum)
 *     __pyx_result = KnownGraph.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_KnownGraph(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle_KnownGraph", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle_KnownGraph__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_KnownGraph__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_known_heads);
  __Pyx_DECREF(__pyx_v___pyx_result->_known_heads);
  __pyx_v___pyx_result->_known_heads = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_nodes);
  __Pyx_DECREF(__pyx_v___pyx_result->_nodes);
  __pyx_v___pyx_result->_nodes = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->do_cache = __pyx_t_2;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 3) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_KnownGraph__set_state(<KnownGraph> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_KnownGraph__set_state(KnownGraph __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._known_heads = __pyx_state[0]; __pyx_result._nodes = __pyx_state[1]; __pyx_result.do_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle_KnownGraph__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle__MergeSortNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_7__pyx_unpickle__MergeSortNode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6breezy_16_known_graph_pyx_7__pyx_unpickle__MergeSortNode = {"__pyx_unpickle__MergeSortNode", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_16_known_graph_pyx_7__pyx_unpickle__MergeSortNode, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_7__pyx_unpickle__MergeSortNode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSortNode (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSortNode", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSortNode", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__MergeSortNode") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSortNode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSortNode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_6__pyx_unpickle__MergeSortNode(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_6__pyx_unpickle__MergeSortNode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSortNode", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x7a2ed2f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x7a2ed2f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x7a2ed2f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x7a2ed2f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x7a, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x7a2ed2f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__MergeSortNode), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSortNode__set_state(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7a2ed2f = (_revno_first, _revno_last, _revno_second, completed, end_of_merge, is_first_child, key, left_parent, left_pending_parent, merge_depth, pending_parents, seen_by_child))" % __pyx_checksum)
 *     __pyx_result = _MergeSortNode.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__MergeSortNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSortNode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSortNode__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSortNode__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_revno_first = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_revno_last = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_revno_second = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->completed = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->end_of_merge);
  __Pyx_DECREF(__pyx_v___pyx_result->end_of_merge);
  __pyx_v___pyx_result->end_of_merge = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->is_first_child = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->key);
  __Pyx_DECREF(__pyx_v___pyx_result->key);
  __pyx_v___pyx_result->key = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->left_parent);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->left_parent));
  __pyx_v___pyx_result->left_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->left_pending_parent);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->left_pending_parent));
  __pyx_v___pyx_result->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->merge_depth = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pending_parents);
  __Pyx_DECREF(__pyx_v___pyx_result->pending_parents);
  __pyx_v___pyx_result->pending_parents = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->seen_by_child = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 12) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":14
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[12])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSortNode__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle__MergeSorter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_9__pyx_unpickle__MergeSorter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6breezy_16_known_graph_pyx_9__pyx_unpickle__MergeSorter = {"__pyx_unpickle__MergeSorter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_16_known_graph_pyx_9__pyx_unpickle__MergeSorter, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6breezy_16_known_graph_pyx_9__pyx_unpickle__MergeSorter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSorter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSorter", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSorter", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__MergeSorter") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__MergeSorter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSorter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6breezy_16_known_graph_pyx_8__pyx_unpickle__MergeSorter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6breezy_16_known_graph_pyx_8__pyx_unpickle__MergeSorter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSorter", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6f5320f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x6f5320f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6f5320f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x6f5320f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x6f_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x6f5320f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6breezy_16_known_graph_pyx__MergeSorter), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSorter__set_state(((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6f5320f = (_depth_first_stack, _last_stack_item, _revno_to_branch_count, _scheduled_nodes, graph))" % __pyx_checksum)
 *     __pyx_result = _MergeSorter.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__MergeSorter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSorter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6breezy_16_known_graph_pyx___pyx_unpickle__MergeSorter__set_state(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle__MergeSorter__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_depth_first_stack);
  __Pyx_DECREF(__pyx_v___pyx_result->_depth_first_stack);
  __pyx_v___pyx_result->_depth_first_stack = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_last_stack_item = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_revno_to_branch_count);
  __Pyx_DECREF(__pyx_v___pyx_result->_revno_to_branch_count);
  __pyx_v___pyx_result->_revno_to_branch_count = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_scheduled_nodes);
  __Pyx_DECREF(__pyx_v___pyx_result->_scheduled_nodes);
  __pyx_v___pyx_result->_scheduled_nodes = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6breezy_16_known_graph_pyx_KnownGraph))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->graph);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->graph));
  __pyx_v___pyx_result->graph = ((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 5) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle__MergeSorter__set_state(<_MergeSorter> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSorter__set_state(_MergeSorter __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._depth_first_stack = __pyx_state[0]; __pyx_result._last_stack_item = __pyx_state[1]; __pyx_result._revno_to_branch_count = __pyx_state[2]; __pyx_result._scheduled_nodes = __pyx_state[3]; __pyx_result.graph = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("breezy._known_graph_pyx.__pyx_unpickle__MergeSorter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__KnownGraphNode __pyx_vtable_6breezy_16_known_graph_pyx__KnownGraphNode;

static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__KnownGraphNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)o);
  p->__pyx_vtab = __pyx_vtabptr_6breezy_16_known_graph_pyx__KnownGraphNode;
  p->key = Py_None; Py_INCREF(Py_None);
  p->parents = Py_None; Py_INCREF(Py_None);
  p->children = Py_None; Py_INCREF(Py_None);
  p->extra = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6breezy_16_known_graph_pyx__KnownGraphNode(PyObject *o) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->key);
  Py_CLEAR(p->parents);
  Py_CLEAR(p->children);
  Py_CLEAR(p->extra);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6breezy_16_known_graph_pyx__KnownGraphNode(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)o;
  if (p->key) {
    e = (*v)(p->key, a); if (e) return e;
  }
  if (p->parents) {
    e = (*v)(p->parents, a); if (e) return e;
  }
  if (p->children) {
    e = (*v)(p->children, a); if (e) return e;
  }
  if (p->extra) {
    e = (*v)(p->extra, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6breezy_16_known_graph_pyx__KnownGraphNode(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)o;
  tmp = ((PyObject*)p->key);
  p->key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->parents);
  p->parents = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->children);
  p->children = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->extra);
  p->extra = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_child_keys(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_10child_keys_1__get__(o);
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_parent_keys(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_11parent_keys_1__get__(o);
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_gdfo(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_gdfo(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_4gdfo_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_6breezy_16_known_graph_pyx__KnownGraphNode[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6breezy_16_known_graph_pyx__KnownGraphNode[] = {
  {(char *)"child_keys", __pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_child_keys, 0, (char *)0, 0},
  {(char *)"parent_keys", __pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_parent_keys, 0, (char *)0, 0},
  {(char *)"gdfo", __pyx_getprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_gdfo, __pyx_setprop_6breezy_16_known_graph_pyx_15_KnownGraphNode_gdfo, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode = {
  PyVarObject_HEAD_INIT(0, 0)
  "breezy._known_graph_pyx._KnownGraphNode", /*tp_name*/
  sizeof(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Represents a single object in the known graph.", /*tp_doc*/
  __pyx_tp_traverse_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_traverse*/
  __pyx_tp_clear_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6breezy_16_known_graph_pyx_15_KnownGraphNode_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6breezy_16_known_graph_pyx__KnownGraphNode, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSorter __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter;

static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__MergeSorter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)o);
  p->__pyx_vtab = __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSorter;
  p->graph = ((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)Py_None); Py_INCREF(Py_None);
  p->_depth_first_stack = Py_None; Py_INCREF(Py_None);
  p->_revno_to_branch_count = Py_None; Py_INCREF(Py_None);
  p->_scheduled_nodes = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6breezy_16_known_graph_pyx__MergeSorter(PyObject *o) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->graph);
  Py_CLEAR(p->_depth_first_stack);
  Py_CLEAR(p->_revno_to_branch_count);
  Py_CLEAR(p->_scheduled_nodes);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6breezy_16_known_graph_pyx__MergeSorter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)o;
  if (p->graph) {
    e = (*v)(((PyObject *)p->graph), a); if (e) return e;
  }
  if (p->_depth_first_stack) {
    e = (*v)(p->_depth_first_stack, a); if (e) return e;
  }
  if (p->_revno_to_branch_count) {
    e = (*v)(p->_revno_to_branch_count, a); if (e) return e;
  }
  if (p->_scheduled_nodes) {
    e = (*v)(p->_scheduled_nodes, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6breezy_16_known_graph_pyx__MergeSorter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *)o;
  tmp = ((PyObject*)p->graph);
  p->graph = ((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_depth_first_stack);
  p->_depth_first_stack = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_revno_to_branch_count);
  p->_revno_to_branch_count = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_scheduled_nodes);
  p->_scheduled_nodes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6breezy_16_known_graph_pyx__MergeSorter[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6breezy_16_known_graph_pyx__MergeSorter = {
  PyVarObject_HEAD_INIT(0, 0)
  "breezy._known_graph_pyx._MergeSorter", /*tp_name*/
  sizeof(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6breezy_16_known_graph_pyx__MergeSorter, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "This class does the work of computing the merge_sort ordering.\n\n    We have some small advantages, in that we get all the extra information\n    that KnownGraph knows, like knowing the child lists, etc.\n    ", /*tp_doc*/
  __pyx_tp_traverse_6breezy_16_known_graph_pyx__MergeSorter, /*tp_traverse*/
  __pyx_tp_clear_6breezy_16_known_graph_pyx__MergeSorter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6breezy_16_known_graph_pyx__MergeSorter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6breezy_16_known_graph_pyx_12_MergeSorter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6breezy_16_known_graph_pyx__MergeSorter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx_KnownGraph __pyx_vtable_6breezy_16_known_graph_pyx_KnownGraph;

static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx_KnownGraph(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)o);
  p->__pyx_vtab = __pyx_vtabptr_6breezy_16_known_graph_pyx_KnownGraph;
  p->_nodes = Py_None; Py_INCREF(Py_None);
  p->_known_heads = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6breezy_16_known_graph_pyx_KnownGraph(PyObject *o) {
  struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->_nodes);
  Py_CLEAR(p->_known_heads);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6breezy_16_known_graph_pyx_KnownGraph(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)o;
  if (p->_nodes) {
    e = (*v)(p->_nodes, a); if (e) return e;
  }
  if (p->_known_heads) {
    e = (*v)(p->_known_heads, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6breezy_16_known_graph_pyx_KnownGraph(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *)o;
  tmp = ((PyObject*)p->_nodes);
  p->_nodes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_known_heads);
  p->_known_heads = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph__nodes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph__nodes(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_3__set__(o, v);
  }
  else {
    return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_6_nodes_5__del__(o);
  }
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph__known_heads(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph__known_heads(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_3__set__(o, v);
  }
  else {
    return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_12_known_heads_5__del__(o);
  }
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph_do_cache(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph_do_cache(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_8do_cache_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_6breezy_16_known_graph_pyx_KnownGraph[] = {
  {"_initialize_nodes", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_5_initialize_nodes, METH_O, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_4_initialize_nodes},
  {"_find_tails", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_7_find_tails, METH_NOARGS, 0},
  {"_find_tips", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_9_find_tips, METH_NOARGS, 0},
  {"_find_gdfo", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_11_find_gdfo, METH_NOARGS, 0},
  {"add_node", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_13add_node, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_12add_node},
  {"heads", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_15heads, METH_O, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_14heads},
  {"topo_sort", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_17topo_sort, METH_NOARGS, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_16topo_sort},
  {"gc_sort", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_19gc_sort, METH_NOARGS, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_18gc_sort},
  {"merge_sort", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_21merge_sort, METH_O, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_20merge_sort},
  {"get_parent_keys", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_23get_parent_keys, METH_O, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_22get_parent_keys},
  {"get_child_keys", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_25get_child_keys, METH_O, __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph_24get_child_keys},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_27__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_29__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6breezy_16_known_graph_pyx_KnownGraph[] = {
  {(char *)"_nodes", __pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph__nodes, __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph__nodes, (char *)0, 0},
  {(char *)"_known_heads", __pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph__known_heads, __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph__known_heads, (char *)0, 0},
  {(char *)"do_cache", __pyx_getprop_6breezy_16_known_graph_pyx_10KnownGraph_do_cache, __pyx_setprop_6breezy_16_known_graph_pyx_10KnownGraph_do_cache, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6breezy_16_known_graph_pyx_KnownGraph = {
  PyVarObject_HEAD_INIT(0, 0)
  "breezy._known_graph_pyx.KnownGraph", /*tp_name*/
  sizeof(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6breezy_16_known_graph_pyx_KnownGraph, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "This is a class which assumes we already know the full graph.", /*tp_doc*/
  __pyx_tp_traverse_6breezy_16_known_graph_pyx_KnownGraph, /*tp_traverse*/
  __pyx_tp_clear_6breezy_16_known_graph_pyx_KnownGraph, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6breezy_16_known_graph_pyx_KnownGraph, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6breezy_16_known_graph_pyx_KnownGraph, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6breezy_16_known_graph_pyx_10KnownGraph_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6breezy_16_known_graph_pyx_KnownGraph, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6breezy_16_known_graph_pyx__MergeSortNode __pyx_vtable_6breezy_16_known_graph_pyx__MergeSortNode;

static PyObject *__pyx_tp_new_6breezy_16_known_graph_pyx__MergeSortNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)o);
  p->__pyx_vtab = __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSortNode;
  p->key = Py_None; Py_INCREF(Py_None);
  p->end_of_merge = Py_None; Py_INCREF(Py_None);
  p->left_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
  p->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
  p->pending_parents = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6breezy_16_known_graph_pyx__MergeSortNode(PyObject *o) {
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->key);
  Py_CLEAR(p->end_of_merge);
  Py_CLEAR(p->left_parent);
  Py_CLEAR(p->left_pending_parent);
  Py_CLEAR(p->pending_parents);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6breezy_16_known_graph_pyx__MergeSortNode(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)o;
  if (p->key) {
    e = (*v)(p->key, a); if (e) return e;
  }
  if (p->end_of_merge) {
    e = (*v)(p->end_of_merge, a); if (e) return e;
  }
  if (p->left_parent) {
    e = (*v)(((PyObject *)p->left_parent), a); if (e) return e;
  }
  if (p->left_pending_parent) {
    e = (*v)(((PyObject *)p->left_pending_parent), a); if (e) return e;
  }
  if (p->pending_parents) {
    e = (*v)(p->pending_parents, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6breezy_16_known_graph_pyx__MergeSortNode(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *)o;
  tmp = ((PyObject*)p->key);
  p->key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->end_of_merge);
  p->end_of_merge = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->left_parent);
  p->left_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->left_pending_parent);
  p->left_pending_parent = ((struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pending_parents);
  p->pending_parents = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_revno(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5revno_1__get__(o);
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_key(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_key(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_3__set__(o, v);
  }
  else {
    return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3key_5__del__(o);
  }
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_merge_depth(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_merge_depth(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_11merge_depth_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_end_of_merge(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__get__(o);
}

static int __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_end_of_merge(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_3__set__(o, v);
  }
  else {
    return __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_6breezy_16_known_graph_pyx__MergeSortNode[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6breezy_16_known_graph_pyx__MergeSortNode[] = {
  {(char *)"revno", __pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_revno, 0, (char *)0, 0},
  {(char *)"key", __pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_key, __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_key, (char *)0, 0},
  {(char *)"merge_depth", __pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_merge_depth, __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_merge_depth, (char *)0, 0},
  {(char *)"end_of_merge", __pyx_getprop_6breezy_16_known_graph_pyx_14_MergeSortNode_end_of_merge, __pyx_setprop_6breezy_16_known_graph_pyx_14_MergeSortNode_end_of_merge, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6breezy_16_known_graph_pyx__MergeSortNode = {
  PyVarObject_HEAD_INIT(0, 0)
  "breezy._known_graph_pyx._MergeSortNode", /*tp_name*/
  sizeof(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Tracks information about a node during the merge_sort operation.", /*tp_doc*/
  __pyx_tp_traverse_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_traverse*/
  __pyx_tp_clear_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6breezy_16_known_graph_pyx_14_MergeSortNode_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6breezy_16_known_graph_pyx__MergeSortNode, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec__known_graph_pyx(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec__known_graph_pyx},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "_known_graph_pyx",
    __pyx_k_Implementation_of_Graph_algorith, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_GraphCycleError, __pyx_k_GraphCycleError, sizeof(__pyx_k_GraphCycleError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x1d, __pyx_k_Incompatible_checksums_s_vs_0x1d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x1d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x6f, __pyx_k_Incompatible_checksums_s_vs_0x6f, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x6f), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x6f_2, __pyx_k_Incompatible_checksums_s_vs_0x6f_2, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x6f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x7a, __pyx_k_Incompatible_checksums_s_vs_0x7a, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x7a), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_KnownGraph, __pyx_k_KnownGraph, sizeof(__pyx_k_KnownGraph), 0, 0, 1, 1},
  {&__pyx_n_s_KnownGraphNode, __pyx_k_KnownGraphNode, sizeof(__pyx_k_KnownGraphNode), 0, 0, 1, 1},
  {&__pyx_n_s_MergeSortNode, __pyx_k_MergeSortNode, sizeof(__pyx_k_MergeSortNode), 0, 0, 1, 1},
  {&__pyx_n_s_MergeSorter, __pyx_k_MergeSorter, sizeof(__pyx_k_MergeSorter), 0, 0, 1, 1},
  {&__pyx_n_s_NULL_REVISION, __pyx_k_NULL_REVISION, sizeof(__pyx_k_NULL_REVISION), 0, 0, 1, 1},
  {&__pyx_kp_s_Parent_key_mismatch_existing_nod, __pyx_k_Parent_key_mismatch_existing_nod, sizeof(__pyx_k_Parent_key_mismatch_existing_nod), 0, 0, 1, 0},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Something_wrong_with_s, __pyx_k_Something_wrong_with_s, sizeof(__pyx_k_Something_wrong_with_s), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_breezy__known_graph_pyx, __pyx_k_breezy__known_graph_pyx, sizeof(__pyx_k_breezy__known_graph_pyx), 0, 0, 1, 1},
  {&__pyx_kp_s_breezy__known_graph_pyx_pyx, __pyx_k_breezy__known_graph_pyx_pyx, sizeof(__pyx_k_breezy__known_graph_pyx_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_child_keys, __pyx_k_child_keys, sizeof(__pyx_k_child_keys), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_deque, __pyx_k_deque, sizeof(__pyx_k_deque), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_do_cache, __pyx_k_do_cache, sizeof(__pyx_k_do_cache), 0, 0, 1, 1},
  {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
  {&__pyx_n_s_find_gdfo, __pyx_k_find_gdfo, sizeof(__pyx_k_find_gdfo), 0, 0, 1, 1},
  {&__pyx_n_s_find_tails, __pyx_k_find_tails, sizeof(__pyx_k_find_tails), 0, 0, 1, 1},
  {&__pyx_n_s_find_tips, __pyx_k_find_tips, sizeof(__pyx_k_find_tips), 0, 0, 1, 1},
  {&__pyx_n_s_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 0, 1, 1},
  {&__pyx_n_s_get_key, __pyx_k_get_key, sizeof(__pyx_k_get_key), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_kp_s_ghost_nodes_should_not_be_pushed, __pyx_k_ghost_nodes_should_not_be_pushed, sizeof(__pyx_k_ghost_nodes_should_not_be_pushed), 0, 0, 1, 0},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_initialize_nodes, __pyx_k_initialize_nodes, sizeof(__pyx_k_initialize_nodes), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_kp_s_key_s_not_in_nodes, __pyx_k_key_s_not_in_nodes, sizeof(__pyx_k_key_s_not_in_nodes), 0, 0, 1, 0},
  {&__pyx_n_s_known_graph, __pyx_k_known_graph, sizeof(__pyx_k_known_graph), 0, 0, 1, 1},
  {&__pyx_kp_s_lst_or_tpl_must_be_a_list_or_tup, __pyx_k_lst_or_tpl_must_be_a_list_or_tup, sizeof(__pyx_k_lst_or_tpl_must_be_a_list_or_tup), 0, 0, 1, 0},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_node, __pyx_k_node, sizeof(__pyx_k_node), 0, 0, 1, 1},
  {&__pyx_n_s_parent_keys, __pyx_k_parent_keys, sizeof(__pyx_k_parent_keys), 0, 0, 1, 1},
  {&__pyx_n_s_parent_map, __pyx_k_parent_map, sizeof(__pyx_k_parent_map), 0, 0, 1, 1},
  {&__pyx_kp_s_parent_map_should_be_a_dict_of_k, __pyx_k_parent_map_should_be_a_dict_of_k, sizeof(__pyx_k_parent_map_should_be_a_dict_of_k), 0, 0, 1, 0},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_popleft, __pyx_k_popleft, sizeof(__pyx_k_popleft), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_KnownGraph, __pyx_k_pyx_unpickle_KnownGraph, sizeof(__pyx_k_pyx_unpickle_KnownGraph), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle__KnownGraphNode, __pyx_k_pyx_unpickle__KnownGraphNode, sizeof(__pyx_k_pyx_unpickle__KnownGraphNode), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle__MergeSortNode, __pyx_k_pyx_unpickle__MergeSortNode, sizeof(__pyx_k_pyx_unpickle__MergeSortNode), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle__MergeSorter, __pyx_k_pyx_unpickle__MergeSorter, sizeof(__pyx_k_pyx_unpickle__MergeSorter), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_real_node, __pyx_k_real_node, sizeof(__pyx_k_real_node), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 1},
  {&__pyx_n_s_revision, __pyx_k_revision, sizeof(__pyx_k_revision), 0, 0, 1, 1},
  {&__pyx_kp_s_s_s_depth_s_rev_s_s_s_first_s_s, __pyx_k_s_s_depth_s_rev_s_s_s_first_s_s, sizeof(__pyx_k_s_s_depth_s_rev_s_s_s_first_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_gdfo_s_par_s_child_s, __pyx_k_s_s_gdfo_s_par_s_child_s, sizeof(__pyx_k_s_s_gdfo_s_par_s_child_s), 0, 0, 1, 0},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_tip_key, __pyx_k_tip_key, sizeof(__pyx_k_tip_key), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 161, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 385, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 451, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 721, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "breezy/_known_graph_pyx.pyx":161
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 *         raise TypeError('lst_or_tpl must be a list or tuple.')             # <<<<<<<<<<<<<<
 *     length = len(lst_or_tpl)
 *     if length == 0 or length == 1:
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_lst_or_tpl_must_be_a_list_or_tup); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "breezy/_known_graph_pyx.pyx":280
 * 
 *         if not PyDict_CheckExact(parent_map):
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')             # <<<<<<<<<<<<<<
 *         # for key, parent_keys in parent_map.iteritems():
 *         pos = 0
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_parent_map_should_be_a_dict_of_k); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "breezy/_known_graph_pyx.pyx":143
 * 
 * 
 * def get_key(node):             # <<<<<<<<<<<<<<
 *     cdef _KnownGraphNode real_node
 *     real_node = node
 */
  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_node, __pyx_n_s_real_node); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
  __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy__known_graph_pyx_pyx, __pyx_n_s_get_key, 143, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 143, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle__KnownGraphNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__6 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__KnownGraphNode, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__8 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);
  __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_KnownGraph, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__10 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__MergeSortNode, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__12 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__MergeSorter, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_31173706 = PyInt_FromLong(31173706L); if (unlikely(!__pyx_int_31173706)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_116732431 = PyInt_FromLong(116732431L); if (unlikely(!__pyx_int_116732431)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_117422769 = PyInt_FromLong(117422769L); if (unlikely(!__pyx_int_117422769)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_128118063 = PyInt_FromLong(128118063L); if (unlikely(!__pyx_int_128118063)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION = Py_None; Py_INCREF(Py_None);
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_6breezy_16_known_graph_pyx__KnownGraphNode = &__pyx_vtable_6breezy_16_known_graph_pyx__KnownGraphNode;
  __pyx_vtable_6breezy_16_known_graph_pyx__KnownGraphNode.clear_references = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *))__pyx_f_6breezy_16_known_graph_pyx_15_KnownGraphNode_clear_references;
  if (PyType_Ready(&__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode.tp_dictoffset && __pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode.tp_dict, __pyx_vtabptr_6breezy_16_known_graph_pyx__KnownGraphNode) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_KnownGraphNode, (PyObject *)&__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  __pyx_ptype_6breezy_16_known_graph_pyx__KnownGraphNode = &__pyx_type_6breezy_16_known_graph_pyx__KnownGraphNode;
  __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSorter = &__pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter._get_ms_node = (struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *))__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__get_ms_node;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter._push_node = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *, long))__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__push_node;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter._pop_node = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *))__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__pop_node;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter._schedule_stack = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *))__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter__schedule_stack;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSorter.topo_order = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSorter *))__pyx_f_6breezy_16_known_graph_pyx_12_MergeSorter_topo_order;
  if (PyType_Ready(&__pyx_type_6breezy_16_known_graph_pyx__MergeSorter) < 0) __PYX_ERR(0, 731, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6breezy_16_known_graph_pyx__MergeSorter.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_16_known_graph_pyx__MergeSorter.tp_dictoffset && __pyx_type_6breezy_16_known_graph_pyx__MergeSorter.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6breezy_16_known_graph_pyx__MergeSorter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6breezy_16_known_graph_pyx__MergeSorter.tp_dict, __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSorter) < 0) __PYX_ERR(0, 731, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MergeSorter, (PyObject *)&__pyx_type_6breezy_16_known_graph_pyx__MergeSorter) < 0) __PYX_ERR(0, 731, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_16_known_graph_pyx__MergeSorter) < 0) __PYX_ERR(0, 731, __pyx_L1_error)
  __pyx_ptype_6breezy_16_known_graph_pyx__MergeSorter = &__pyx_type_6breezy_16_known_graph_pyx__MergeSorter;
  __pyx_vtabptr_6breezy_16_known_graph_pyx_KnownGraph = &__pyx_vtable_6breezy_16_known_graph_pyx_KnownGraph;
  __pyx_vtable_6breezy_16_known_graph_pyx_KnownGraph._get_or_create_node = (struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *, PyObject *))__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__get_or_create_node;
  __pyx_vtable_6breezy_16_known_graph_pyx_KnownGraph._populate_parents = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx_KnownGraph *, struct __pyx_obj_6breezy_16_known_graph_pyx__KnownGraphNode *, PyObject *))__pyx_f_6breezy_16_known_graph_pyx_10KnownGraph__populate_parents;
  if (PyType_Ready(&__pyx_type_6breezy_16_known_graph_pyx_KnownGraph) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6breezy_16_known_graph_pyx_KnownGraph.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_16_known_graph_pyx_KnownGraph.tp_dictoffset && __pyx_type_6breezy_16_known_graph_pyx_KnownGraph.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6breezy_16_known_graph_pyx_KnownGraph.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6breezy_16_known_graph_pyx_KnownGraph, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 197, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6breezy_16_known_graph_pyx_10KnownGraph___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6breezy_16_known_graph_pyx_10KnownGraph___init__.doc = __pyx_doc_6breezy_16_known_graph_pyx_10KnownGraph___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6breezy_16_known_graph_pyx_10KnownGraph___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_6breezy_16_known_graph_pyx_KnownGraph.tp_dict, __pyx_vtabptr_6breezy_16_known_graph_pyx_KnownGraph) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_KnownGraph, (PyObject *)&__pyx_type_6breezy_16_known_graph_pyx_KnownGraph) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_16_known_graph_pyx_KnownGraph) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  __pyx_ptype_6breezy_16_known_graph_pyx_KnownGraph = &__pyx_type_6breezy_16_known_graph_pyx_KnownGraph;
  __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSortNode = &__pyx_vtable_6breezy_16_known_graph_pyx__MergeSortNode;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSortNode.has_pending_parents = (int (*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *))__pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode_has_pending_parents;
  __pyx_vtable_6breezy_16_known_graph_pyx__MergeSortNode._revno = (PyObject *(*)(struct __pyx_obj_6breezy_16_known_graph_pyx__MergeSortNode *))__pyx_f_6breezy_16_known_graph_pyx_14_MergeSortNode__revno;
  if (PyType_Ready(&__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode) < 0) __PYX_ERR(0, 673, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6breezy_16_known_graph_pyx__MergeSortNode.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode.tp_dictoffset && __pyx_type_6breezy_16_known_graph_pyx__MergeSortNode.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6breezy_16_known_graph_pyx__MergeSortNode.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode.tp_dict, __pyx_vtabptr_6breezy_16_known_graph_pyx__MergeSortNode) < 0) __PYX_ERR(0, 673, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MergeSortNode, (PyObject *)&__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode) < 0) __PYX_ERR(0, 673, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode) < 0) __PYX_ERR(0, 673, __pyx_L1_error)
  __pyx_ptype_6breezy_16_known_graph_pyx__MergeSortNode = &__pyx_type_6breezy_16_known_graph_pyx__MergeSortNode;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC init_known_graph_pyx(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC init_known_graph_pyx(void)
#else
__Pyx_PyMODINIT_FUNC PyInit__known_graph_pyx(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit__known_graph_pyx(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec__known_graph_pyx(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module '_known_graph_pyx' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__known_graph_pyx(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("_known_graph_pyx", __pyx_methods, __pyx_k_Implementation_of_Graph_algorith, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_breezy___known_graph_pyx) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "breezy._known_graph_pyx")) {
      if (unlikely(PyDict_SetItemString(modules, "breezy._known_graph_pyx", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "breezy/_known_graph_pyx.pyx":59
 *     )
 * 
 * import collections             # <<<<<<<<<<<<<<
 * import gc
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":60
 * 
 * import collections
 * import gc             # <<<<<<<<<<<<<<
 * 
 * from . import errors, revision
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gc, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gc, __pyx_t_1) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":62
 * import gc
 * 
 * from . import errors, revision             # <<<<<<<<<<<<<<
 * 
 * cdef object NULL_REVISION
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_errors);
  __Pyx_GIVEREF(__pyx_n_s_errors);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_errors);
  __Pyx_INCREF(__pyx_n_s_revision);
  __Pyx_GIVEREF(__pyx_n_s_revision);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_revision);
  __pyx_t_2 = __Pyx_Import(__pyx_kp_s__3, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_errors, __pyx_t_1) < 0) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_revision); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_revision, __pyx_t_1) < 0) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "breezy/_known_graph_pyx.pyx":65
 * 
 * cdef object NULL_REVISION
 * NULL_REVISION = revision.NULL_REVISION             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_revision); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NULL_REVISION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION);
  __Pyx_DECREF_SET(__pyx_v_6breezy_16_known_graph_pyx_NULL_REVISION, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":143
 * 
 * 
 * def get_key(node):             # <<<<<<<<<<<<<<
 *     cdef _KnownGraphNode real_node
 *     real_node = node
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_16_known_graph_pyx_1get_key, NULL, __pyx_n_s_breezy__known_graph_pyx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_key, __pyx_t_1) < 0) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__KnownGraphNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_16_known_graph_pyx_3__pyx_unpickle__KnownGraphNode, NULL, __pyx_n_s_breezy__known_graph_pyx); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__KnownGraphNode, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle__KnownGraphNode__set_state(<_KnownGraphNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__KnownGraphNode__set_state(_KnownGraphNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.children = __pyx_state[0]; __pyx_result.extra = __pyx_state[1]; __pyx_result.gdfo = __pyx_state[2]; __pyx_result.key = __pyx_state[3]; __pyx_result.parents = __pyx_state[4]; __pyx_result.seen = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_16_known_graph_pyx_5__pyx_unpickle_KnownGraph, NULL, __pyx_n_s_breezy__known_graph_pyx); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_KnownGraph, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__MergeSortNode(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_16_known_graph_pyx_7__pyx_unpickle__MergeSortNode, NULL, __pyx_n_s_breezy__known_graph_pyx); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__MergeSortNode, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle__MergeSortNode__set_state(<_MergeSortNode> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__MergeSortNode__set_state(_MergeSortNode __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._revno_first = __pyx_state[0]; __pyx_result._revno_last = __pyx_state[1]; __pyx_result._revno_second = __pyx_state[2]; __pyx_result.completed = __pyx_state[3]; __pyx_result.end_of_merge = __pyx_state[4]; __pyx_result.is_first_child = __pyx_state[5]; __pyx_result.key = __pyx_state[6]; __pyx_result.left_parent = __pyx_state[7]; __pyx_result.left_pending_parent = __pyx_state[8]; __pyx_result.merge_depth = __pyx_state[9]; __pyx_result.pending_parents = __pyx_state[10]; __pyx_result.seen_by_child = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_16_known_graph_pyx_9__pyx_unpickle__MergeSorter, NULL, __pyx_n_s_breezy__known_graph_pyx); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__MergeSorter, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "breezy/_known_graph_pyx.pyx":1
 * # Copyright (C) 2009, 2010 Canonical Ltd             # <<<<<<<<<<<<<<
 * #
 * # This program is free software; you can redistribute it and/or modify
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init breezy._known_graph_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init breezy._known_graph_pyx");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* pyfrozenset_new */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
    if (it) {
        PyObject* result;
#if CYTHON_COMPILING_IN_PYPY
        PyObject* args;
        args = PyTuple_Pack(1, it);
        if (unlikely(!args))
            return NULL;
        result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
        Py_DECREF(args);
        return result;
#else
        if (PyFrozenSet_CheckExact(it)) {
            Py_INCREF(it);
            return it;
        }
        result = PyFrozenSet_New(it);
        if (unlikely(!result))
            return NULL;
        if (likely(PySet_GET_SIZE(result)))
            return result;
        Py_DECREF(result);
#endif
    }
#if CYTHON_USE_TYPE_SLOTS
    return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#else
    return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#endif
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* py_dict_pop */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
    if ((1)) {
        return _PyDict_Pop(d, key, default_value);
    } else
#endif
    if (default_value) {
        return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
    } else {
        return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
    }
}

/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* PyObjectCallMethod0 */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method = NULL, *result = NULL;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_CallOneArg(method, obj);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* CallUnboundCMethod0 */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* pop */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        Py_SIZE(L) -= 1;
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
    return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
}
#endif

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
