class NodeClass(Base):
    __tablename__ = 'nodes_table'
node_id = Column(Integer, primary_key=True)
left_id = Column(Integer, ForeignKey('nodes_table.node_id'))
left = relationship('NodeClass', remote_side=[node_id], primaryjoin=
    'NodeClass.left_id==NodeClass.node_id', backref=backref('right',
    uselist=False))
Using SQLAlchemy with multiple self-referential foreign keys